5

我尝试用 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
4

3 回答 3

3

该错误消息具有误导性 - 它只是一个编译警告,而不是失败。这可能与http://jira.codehaus.org/browse/MCOMPILER-179有关。尝试升级到 Maven 3.0.5(或最新的 3.1.x)或更新 POM 中的 maven 编译器插件的版本。

于 2013-10-17T09:11:51.997 回答
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>
于 2017-10-08T08:27:29.930 回答
0

好的。谢谢你们。我解决了添加SuppressWarning("deprecation")到问题类的问题。但仍然不确定它对 maven 有什么影响..

于 2013-10-17T12:55:30.360 回答