maven-compiler-plugin 中使用的 release 标签/属性和 compilerVersion 标签/属性之间的区别升级到 Java 11 时的问题

问题描述

release 中使用的 compilerVersion tag/property 和 maven-compiler-plugin tag/property 有什么区别,因为我们在构建时使用 release 标签升级到 java 11 时遇到问题<compilerVersion>11<compilerVersion> 在 pom.xml 中它可以工作但是当我们使用 <release>11</release>

时失败并出现以下错误

错误

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Test: Fatal error compiling: invalid flag: --release -> [Help 1]
10:54:54 [ERROR] 
10:54:54 [ERROR] To see the full stack trace of the errors,re-run Maven with the -e switch.
10:54:54 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
10:54:54 [ERROR] 
10:54:54 [ERROR] For more information about the errors and possible solutions,please read the following articles:
10:54:54 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

解决方法

<compilerVersion>

要使用的编译器版本 [...],如果 fork 设置为 true

<release>

Java 编译器的 -release 参数,自 Java9 起支持

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...