【发布时间】:2021-10-09 00:14:25
【问题描述】:
我已经搜索了几个小时的解决方案,甚至找不到 1 篇关于 maven 编译到 1.16 的帖子
我最近决定将我的一个项目从 java 8 升级到 16,所以我安装了 16 个 JDK 并相应地更改了我的构建部分(在 pom.xml 中):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.16</source> //used to be 1.8
<target>1.16</target> //used to be 1.8
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
但我在尝试安装时收到以下错误:
[INFO] Total time: 0.628 s
[INFO] Finished at: 2021-08-03T22:40:27+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project employeme: Fatal error compiling: error: invalid target release: 1.16 -> [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
【问题讨论】:
-
请查看
mvn --version显示的内容?如果不是我所期望的,应该有关于 JDK16 的输出信息。你必须更改 JAVA_HOME 环境变量以指向 JDK16 以使用 JDK 16 构建...... -
如何从 Eclipse 运行这个命令?另外我已经把我的 JAVA_HOME 放到了 jdk 16... 没有工作
-
不是来自 Eclipse 内部的普通命令行...实际上没有意义...
-
cmd 无法识别“mvn”...
-
你当然必须安装 Maven 才能运行它......maven.apache.org/download.cgi 并安装它:maven.apache.org/install.html
标签: java maven build compilation upgrade