工程项目中同时包含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