使用Maven的編譯器插件,可以指定要用於項目的支持的JDK:指定每個行家子模塊JDK - 屢建,如果錯用
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<fork>true</fork>
<!-- <executable>path-to-javac</executable> -->
<compilerVersion>1.5</compilerVersion>
</configuration>
</plugin>
但是,它可能失敗構建是否使用了另一個JDK版本?
我有一些代碼使用javax.xml.bind.annotation.adapters它不是1.5的一部分,但是因爲我使用包含此包的JDK6構建,所以構建成功。
在eclipse中我收到警告,但它可能是很好的使構建失敗,沒有明確修改構建項目時使用的JDK。
我已經試過這樣:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.5</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
但不起任何作用。我也試過插入插件管理:
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
但是也沒有效果。