的pom.xml:斯卡拉,Maven的插件混合編譯不包括的src/main/java和無法找到java類
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
代碼結構:
src/main/java
Hello.java
src/main/scala #will reference the class under /src/main/java
App.scala
IDE:的IntelliJ IDEA 2017.2.1,JDK:java8
發佈: 當我運行maven編譯通過intellij,它總是顯示錯誤,這意味着它找不到Hello.class。
問題:
爲什麼這個pom.xml中不起作用?我檢查了scal-maven-plugin的文檔,佈局應該可行,但它沒有。
我發現它會工作,如果我通過build-helper-maven-plugin將src/main/java添加爲源目錄。這可以解釋第一個問題,但是我意識到在maven編譯之前,我通過Intellij運行App.scala,所以Hello.java已經編譯到類中,我可以在src/main/target /類。那麼爲什麼scala-maven-plugin在src/main/target/classes下找不到這個類?
謝謝!它解決了我的擔憂。 – Keith