Java 项目编译提示 --release 错误


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] -> [Help 1]
[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] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
[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 的时候报错。