Java 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28826839/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:54:22  来源:igfitidea点击:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile

javamavenmaven-2maven-compiler-plugin

提问by panwar001

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project mrlda: Compilation failure: Compilation failure:

[ERROR] /home/panwar/Downloads/Mr.LDA-master/src/main/java/cc/mrlda/polylda/TermReducer.java:[24,11] error: generics are not supported in -source 1.3

[ERROR] 
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] /home/panwar/Downloads/Mr.LDA-master/src/main/java/cc/mrlda/TermReducer.java:[33,11] error: generics are not supported in -source 1.3 

I'm using latest version of java.

我正在使用最新版本的java。

Solved: The problem was with maven. I was using an older version(maven3.0.2) other things were correct.

已解决:问题出在 maven 上。我使用的是旧版本(maven3.0.2)其他事情是正确的。

回答by Jens

You compile your code for java 1.3 and use generics, which was introduced in java 1.5. You have to change to java 1.5 or higher.

您为 java 1.3 编译代码并使用在 java 1.5 中引入的泛型。您必须更改为 java 1.5 或更高版本。

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>

回答by JBA

You may want to use a higher JDK-("Java"-) Version for the compiler plugin like:

您可能希望为编译器插件使用更高的 JDK-("Java"-) 版本,例如:

<plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.2</version>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
      </configuration>
    </plugin>

回答by Peraiah Karanam

Your Maven is reading Java version as 1.6.0_65, Where as the pom.xml says the version is 1.7.

您的 Maven 将 Java 版本读取为 1.6.0_65,而 pom.xml 表示版本为 1.7。

Try installing the required verison.

尝试安装所需的版本。

If already installed check your $JAVA_HOMEenvironment variable, it should contain the path of Java JDK 7. If you don't find it, fix your environment variable.

如果已经安装,请检查您的$JAVA_HOME环境变量,它应该包含 Java JDK 7 的路径。如果没有找到,请修复您的环境变量。

also remove the lines:

也删除行:

 <fork>true</fork>
 <executable>${JAVA_1_7_HOME}/bin/javac</executable>

from the pom.xml

来自 pom.xml