- 打开pom.xml文件,添加maven插件和Scala SDK
- 新建scala目录并刷新maven, 此时scala目录自动被标记为Source Root,可以创建Scala类和对象了
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
说明1:scala-maven-plugin 主要作用是使得maven能够编译Scala代码
说明2:scala-library 使得IDEA的Scala插件自动添加Scala的SDK,不再需要手动指定添加了。