Maven 3.8.0编译器-致命错误编译:不支持版本11 [英] Maven 3.8.0 Compiler - Fatal error compiling: release version 11 not supported

查看:155
本文介绍了Maven 3.8.0编译器-致命错误编译:不支持版本11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Java 11和最新版本的maven-compiler-plugin进行构建.

I'm unable to build using Java 11 with the latest version of the maven-compiler-plugin.

pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
    <plugins>
<build>

当我尝试使用Maven进行构建时:

when I try to build using Maven:

➜  mvn clean compile
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building service 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 80 source files to /home/mip/service/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.859 s
[INFO] Finished at: 2018-08-01T11:20:55+01:00
[INFO] Final Memory: 32M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project service: Fatal error compiling: release version 11 not supported -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

以下是我正在使用的Maven和Java版本:

Here are the Maven and Java versions which I am using:

➜  mvn -version
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 10.0.1, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-29-generic", arch: "amd64", family:     "unix"
➜  /usr/lib/jvm/java-11-openjdk-amd64/bin/java -version
openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)

是否可能将Java 11标识为"10.0.1"?如果我将pom.xml修改为<release>10</release>,则即使没有安装Java 10,它也不会生成任何问题.

Could Java 11 identifying itself as "10.0.1" be causing the problem? If I modify my pom.xml to <release>10</release> then it builds with no issue, even though I do not have Java 10 installed.

➜  ~ /usr/lib/jvm/java-11-openjdk-amd64/bin/javac -version
javac 10.0.1 

➜ javac --release 11 SomeClass.java
javac: release version 11 not 
supported Usage: javac <options> <source files>
use --help for a list of possible options

我认为这是Ubuntu openjdk-11-jdk软件包的问题:

I think this is an issue with the Ubuntu openjdk-11-jdk package:

➜  ~ sudo apt install openjdk-11-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openjdk-11-jdk is already the newest version (10.0.1+10-3ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 2 not to upgrade.

推荐答案

mvn需要设置JAVA_HOME.我遇到了同样的问题,并设置了JAVA_HOME来纠正JDK的问题.

mvn need JAVA_HOME to be set. I faced the same issue and setting up JAVA_HOME to correct JDK did the trick.

这篇关于Maven 3.8.0编译器-致命错误编译:不支持版本11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆