【问题标题】:Maven Java error compiling on build: maven-compiler-plugin构建时编译 Maven Java 错误:maven-compiler-plugin
【发布时间】:2021-02-07 00:42:28
【问题描述】:

当我尝试以 maven build 运行时,它总是给BUILD FAILURE

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project testJPA: Fatal error compiling: invalid target release: 11 -> [Help 1]

我已经尝试了以下方法:

  • 删除 .m2 文件夹
  • 重新安装eclipse
  • 在 pom.xml 上设置可执行文件
  • 将构建选项设置为清理
> java -version
java version "1.8.0_261"

> echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_211

pom.xml

<plugin>
    <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>11</source>
        <target>11</target>
        <encoding>UTF-8</encoding>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
    </configuration>
</plugin>

他们都没有工作。有什么猜测吗?

【问题讨论】:

  • 这可能与 Java 11 有关。您安装了 java 11 吗?看看这个:stackoverflow.com/questions/63154787/…
  • 我用结果更新了我的问题
  • 我看到很多关于在 pom.xml 中设置版本的建议。您可以将您的 pom.xml 内容添加到问题中吗?
  • “mvn –version”在命令行产生什么?
  • 因为我没有 Apache Maven 它没有那个命令。

标签: java maven


【解决方案1】:

我设法找到了解决方案。

我安装了 JDK 11 并将其设置在 Window > Preferences > Java > Installed JREs > 添加 > jdk-11.0.9

下载地址:https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-18
    • 2015-05-27
    • 2020-08-13
    • 2016-02-17
    • 2017-07-20
    • 2018-11-25
    • 2017-11-26
    相关资源
    最近更新 更多