寫在前面:基本上靠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>