我尝试用maven构建一个java项目。我使用java 7但是maven源是1.6。我无法改变它。当我运行“mvn clean install”时,它失败并出现一个奇怪的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project search: Compilation failure
[ERROR] could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6
[ERROR] /someClassName.java:114: warning: [deprecation] LUCENE_36 in Version has been deprecated
[ERROR] out = new ICUCollationKeyAnalyzer(Version.LUCENE_36, l);
[ERROR] ^
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project search: Compilation failure
could not parse error message: warning: [options] bootstrap class path not set in conjunction with -source 1.6
/someClassName.java:114: warning: [deprecation] LUCENE_36 in Version has been deprecated
out = new ICUCollationKeyAnalyzer(Version.LUCENE_36, l);
目前,我不会像maven推荐的那样更改lucene版本。所以,我想知道为什么maven关心代码中弃用的东西以及如何避免这些错误?感谢。
Apache Maven 3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
答案 0 :(得分:3)
错误消息具有误导性 - 它只是编译警告,而不是失败。这可能与http://jira.codehaus.org/browse/MCOMPILER-179有关。尝试升级到Maven 3.0.5(或最新的3.1.x)或更新POM中maven编译器插件的版本。
答案 1 :(得分:1)
为了详细说明这个主题,您可以使用showWarnings配置来强制显示编辑警告的开/关。
将其设置为false(如果它适合您),以便首先隐藏警告。
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>false</showWarnings>
</configuration>
</plugin>
</plugins>
答案 2 :(得分:0)
确定。谢谢你们。我解决了将SuppressWarning("deprecation")
添加到问题类的问题。但仍然不确定它对maven有什么不同..