上一篇讲述了 如果 通过 maven 提供的 构建工具去创建 scala 项目,
但是其实并不需要这么复杂的构建流程,
这篇主要讲解一个简单的构建流程,来帮助我们进行构建 。
1) 进行初始化设置,设置 scala 为项目默认配置
2) 创建 maven 项目
3) 修改 pom.xml
4) 创建测试类,测试
1) 进行初始化设置,设置 scala 为项目默认配置
设置scala的项目默认SDK
并且拷贝到lib 下面
2)创建 maven 项目
3) 修改 pom.xml
修改后的pom.xml
<properties>
<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>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.8</arg>
</args>
</configuration>
</plugin>
</plugins>
</build>
4) 创建测试类,测试
创建测试类:
代码如下:
/**
* Created by szh on 2018/9/14.
*/
object TestCC {
def main(args: Array[String]) {
var zz = "fast fast fast"
println(s"$zz, better better better")
}
}
运行测试代码: