写在前面:基本上靠java吃饭的吧,近两年也有用到scala;但也没有留下什么痕迹,想起每次被问倒在基础知识,那刻对方→_→ 怀疑的眼神~~。so right here, right now ! 今后沉淀下来。而后积沙成堆,积水成河 养成良好的习惯并锲而不舍。p( ^ O ^ )q 加油!php
1、IDE:scala-IDE(一直用这个),IntelliJ IDEA(耳闻),Netbeans(才知道)html
2、安装m2eclipse-scala插件,URL:http://alchim31.free.fr/m2e-scala/update-site/java
3、建立项目的时候须要搜索、选择插件,要增长URL:http://repo1.maven.org/maven2/archetype-catalog.xmlgit
4、出现过mvn连不上公共库的问题;github
解决方法:eclipse.ini add : -vmargs -Djava.net.preferIPv4Stack=trueapache
参考https://www.eclipse.org/forums/index.php/t/270718/(Starting Eclipse with -vmargs -Djava.net.preferIPv4Stack=true works for me)eclipse
5、建立支持scala的mvn项目步骤maven
Select New -> Project -> Other and then select Maven Project. On the next window, search forscala-archetype
. Make sure you select the one in group net.alchim31.maven
, and click Next。
ide
参考http://scala-ide.org/docs/tutorials/m2eclipse/index.html#create-a-new-scala-maven-projectui
6、scala/java 项目mvn打包
参考http://davidb.github.io/scala-maven-plugin/example_java.html
1 <dependencies> 2 ... 3 <dependency> 4 <groupId>org.scala-lang</groupId> 5 <artifactId>scala-library</artifactId> 6 <version>${scala.version}</version> 7 </dependency> 8 ... 9 </dependencies> 10 11 <build> 12 <sourceDirectory>src/main</sourceDirectory> 13 <testSourceDirectory>src/test</testSourceDirectory> 14 15 <pluginManagement> 16 <plugins> 17 <plugin> 18 <groupId>net.alchim31.maven</groupId> 19 <artifactId>scala-maven-plugin</artifactId> 20 <version>3.2.1</version> 21 </plugin> 22 <plugin> 23 <groupId>org.apache.maven.plugins</groupId> 24 <artifactId>maven-compiler-plugin</artifactId> 25 <version>3.2</version> 26 </plugin> 27 </plugins> 28 </pluginManagement> 29 30 <plugins> 31 32 <plugin> 33 <groupId>net.alchim31.maven</groupId> 34 <artifactId>scala-maven-plugin</artifactId> 35 <executions> 36 <execution> 37 <id>scala-compile-first</id> 38 <phase>process-resources</phase> 39 <goals> 40 <goal>add-source</goal> 41 <goal>compile</goal> 42 </goals> 43 </execution> 44 <execution> 45 <id>scala-test-compile</id> 46 <phase>process-test-resources</phase> 47 <goals> 48 <goal>testCompile</goal> 49 </goals> 50 </execution> 51 </executions> 52 </plugin> 53 <plugin> 54 <groupId>org.apache.maven.plugins</groupId> 55 <artifactId>maven-compiler-plugin</artifactId> 56 <executions> 57 <execution> 58 <phase>compile</phase> 59 <goals> 60 <goal>compile</goal> 61 </goals> 62 </execution> 63 </executions> 64 </plugin> 65 </plugins> 66 </build>