Java 项目编译提示 --release 错误提示的错误信息:
代码语言:javascript复制INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project core-java-9: Compilation failure
[ERROR] exporting a package from system module java.base is not allowed with --release
[ERROR]
[ERROR] -> [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/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :core-java-9
问题和解决
出现上面错误的原因是 JDK9 开始,–release 和 --add-exports 参数不能同时使用。
在我们的项目编译的时候添加了 --add-exports 参数。
这个会在 JDK 9 的时候报错。
我们可以把这个参数从编译环境中删除。