gpt4 book ai didi

scala - 用 Maven 创建最基本的 Scala 项目?

转载 作者:行者123 更新时间:2023-12-03 21:52:00 24 4
gpt4 key购买 nike

我使用 Maven 3 创建一个新的 Scala 项目。据我了解,使用 Maven 创建新项目的方法是:

mvn archetype:generate

也许我遗漏了一些东西,但我什至找不到提供最简单 Scala 项目的选项(例如 lein new app ... 为 Clojure 收到的项目)。这里有什么帮助吗?

最佳答案

您应该可以使用 mvn archetype:generate .您可以选择,例如 org.scala-tools.archetypes:scala-archetype-simple .您需要在原型(prototype)名称旁边输入数字编号 在您的 mvn archetype:generate 的输出中命令 因为编号会随着时间而改变。还有其他选项,如 eu.stratosphere:quickstart-scalathis article 中所述.

不过,它们可能有些过时了。我个人更喜欢写我的pom.xml手动文件。作为引用,这是一个用于 Scala 2.11.6 和 Scalatest 2.2.5 的最小 pom 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-artifact</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<encoding>UTF-8</encoding>
<scala.version>2.11.6</scala.version>
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>

<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.5</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</build>
</project>

关于scala - 用 Maven 创建最基本的 Scala 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37047186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com