scala与java混合编译出现的问题

工程项目中同时包含scala和java代码,如果在java中调用scala的类,编译时可能会报找不到scala类的错误,出现这种问题的解决办法是需要对scala进行先行编译,具体需要在pom文件中添加一下plugin: 

 
  1. <plugin>

  2. <groupId>org.apache.maven.plugins</groupId>

  3. <artifactId>maven-compiler-plugin</artifactId>

  4. <configuration>

  5. <source>1.8</source>

  6. <target>1.8</target>

  7. <encoding>UTF-8</encoding>

  8. <maxmem>1024m</maxmem>

  9. <fork>true</fork>

  10. <compilerArgs>

  11. <arg>-Xlint:all,-serial,-path</arg>

  12. </compilerArgs>

  13. </configuration>

  14. </plugin>

  15.  
  16. <plugin>

  17. <groupId>net.alchim31.maven</groupId>

  18. <artifactId>scala-maven-plugin</artifactId>

  19. <executions>

  20. <execution>

  21. <id>scala-compile-first</id>

  22. <phase>process-resources</phase>

  23. <goals>

  24. <goal>add-source</goal>

  25. <goal>compile</goal>

  26. </goals>

  27. </execution>

  28. </executions>

  29. </plugin>

--------------------- 本文来自 RacingHeart 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/u012477420/article/details/80040990?utm_source=copy

猜你喜欢

转载自blog.csdn.net/hellozhxy/article/details/82897792