我无法使用带有最新版本的 maven-编译器-插件的 Java 11 进行构建。
绒球.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 构建时:
➜ 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版本:
➜ 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
➜ ~ /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
软件包的问题:
➜ ~ 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.
对我来说,这是由于安装了Java 11 JRE,而不是JDK。文件夹名称中包含“jdk”,因此我认为它是正确的,但是在 /bin
文件夹中查找我没有看到 javac
可执行文件,因此我认为它正在回退到系统上的默认 Java 早于 Java 11。
我在 docker 容器中构建 java 项目时遇到了此错误。它一定与 maven 的安装方式有关,因为当我将我的容器基于官方 maven 映像时,它就消失了。
特别是,这意味着在我的 Dockerfile 中使用以下内容:
FROM maven:3.6.3-jdk-11-slim
经过进一步调查,关键的区别在于我有软件包java-11-openjdk,但我需要java-11-openjdk-devel
。
需要设置JAVA_HOME
MVN。我遇到了同样的问题,设置JAVA_HOME
来纠正JDK就可以了。
最近我实现了一个新的构建器与gradle运行詹金斯。我们的项目包含jasper报告,所以我在下面添加了一个由jasper报告api提供的蚂蚁任务来编译jasper报告。 一切都很好,编译和预期的工作,但在部署项目到服务器后,在运行时得到以下错误。 [8/3/17 14:38:53:340 EET] 000000f5 SystemOut O ERROR[14:38:53,333-WebContain
在macOS Catalina 10.15.4上,我安装了jdk-10.0.1。 当我进入终端并输入: 标准输出: Java版本: 创建了一个示例maven项目,并将JUnit 5设置为依赖项: 计算器类: JUnit 5测试: 当我通过Terminal或IntelliJ IDEA Ultimate Edition 2019.3(作为Maven run config
我正在IntelliJ上运行一个Java Maven项目,我确保这个项目将由Java1.8编译。 而且 当我运行该项目时,我得到一个错误: 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.0:project feed_matcher上的compile(default-compile):编译错误:无效的目标版本:1.8->[帮助1] 你知
我想使用代码扫描工具CodeQL。我按照指南中的步骤使用github操作启用代码扫描。但我从管道中得到以下错误消息: 如何更改CodeQL的java版本?如何让管道再次工作?
从Eclipse运行install时,我们没有问题,因为编译器版本设置为1.8。 在终端上运行mvn安装时,我们得到以下错误。 当使用mvn install-X时,我们看到目标1.5 然而,这里是我的java和javac版本 我似乎从我运行的每个版本中,我们应该有1.8的合规性,但maven目标继续尝试安装1.5的合规性。
当我运行这个命令时,我试图将我的后端应用程序部署到heroku bun 我得到这个错误 这是我的pom文件: