scala与java混合编译出现的问题
工程項目中同時包含scala和java代碼,如果在java中調用scala的類,編譯時可能會報找不到scala類的錯誤,出現這種問題的解決辦法是需要對scala進行先行編譯,具體需要在pom文件中添加一下plugin:?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<maxmem>1024m</maxmem>
<fork>true</fork>
<compilerArgs>
<arg>-Xlint:all,-serial,-path</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
--------------------- 本文來自 RacingHeart 的CSDN 博客 ,全文地址請點擊:https://blog.csdn.net/u012477420/article/details/80040990?utm_source=copy
總結
以上是生活随笔為你收集整理的scala与java混合编译出现的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MapReduce Job集群提交过程源
- 下一篇: 机器学习算法实现解析:libFM之lib