基于maven配置的scala开发环境,首先需要安装 idea 的scala plugin.然后就可以使用maven编译scala程序了.一般情况下都是java scala的混合,所以src下面有java scala两个源文件目录.
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>org.nuke</groupId> 8 <artifactId>scala-example</artifactId> 9 <version>1.0-SNAPSHOT</version> 10 <properties> 11 <jackson.version>2.4.2</jackson.version> 12 <scala.version>2.11.1</scala.version> 13 <slf4j.version>1.7.7</slf4j.version> 14 <scala.maven.version>2.11.1</scala.maven.version> 15 </properties> 16 17 <repositories> 18 <repository> 19 <id>scalaz</id> 20 <name>scalaz</name> 21 <url>http://dl.bintray.com/scalaz/releases</url> 22 </repository> 23 <repository> 24 <id>mvnrepository</id> 25 <name>Derbysoft Release Repository</name> 26 <url>http://search.maven.org/remotecontent?filepath=</url> 27 </repository> 28 29 30 <repository> 31 <id>jahia</id> 32 <name>mvnrepository</name> 33 <url>http://maven.jahia.org/maven2</url> 34 </repository> 35 36 </repositories> 37 38 <dependencies> 39 <dependency> 40 <groupId>org.scala-lang</groupId> 41 <artifactId>scala-library</artifactId> 42 <version>${scala.version}</version> 43 <scope>compile</scope> 44 </dependency> 45 <dependency> 46 <groupId>org.scala-lang</groupId> 47 <artifactId>scala-compiler</artifactId> 48 <version>${scala.version}</version> 49 <scope>compile</scope> 50 </dependency> 51 52 <dependency> 53 <groupId>org.specs2</groupId> 54 <artifactId>specs2_2.11</artifactId> 55 <version>2.4.6</version> 56 <scope>test</scope> 57 </dependency> 58 </dependencies> 59 <build> 60 <plugins> 61 <plugin> 62 <groupId>net.alchim31.maven</groupId> 63 <artifactId>scala-maven-plugin</artifactId> 64 <version>3.2.0</version> 65 <executions> 66 <execution> 67 <id>compile-scala</id> 68 <phase>compile</phase> 69 <goals> 70 <goal>add-source</goal> 71 <goal>compile</goal> 72 </goals> 73 </execution> 74 <execution> 75 <id>test-compile-scala</id> 76 <phase>test-compile</phase> 77 <goals> 78 <goal>add-source</goal> 79 <goal>testCompile</goal> 80 </goals> 81 </execution> 82 </executions> 83 <configuration> 84 <scalaVersion>${scala.version}</scalaVersion> 85 </configuration> 86 </plugin> 87 </plugins> 88 </build></project> 89