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

**URL:** <https://www.isharkfly.com/t/java-release/15702>\
**Category:** 程序语言\
**Tags:** java, maven\
**Created:** [May 2, 2024, 1:58am UTC](https://www.isharkfly.com/t/java-release/15702 "2024-05-02T01:58:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [May 2, 2024, 1:58am UTC](https://www.isharkfly.com/t/java-release/15702/1 "2024-05-02T01:58:18Z")

</div>

提示的错误信息：

```plaintext
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

```

 ![2024-05-01_21-55-45](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/2X/a/afd6d9b223826a82d1fd778bbd4be924bf58138e.png)

## 问题和解决

出现上面错误的原因是 JDK9 开始，–release 和 --add-exports 参数不能同时使用。

在我们的项目编译的时候添加了 --add-exports 参数。

这个会在 JDK 9 的时候报错。

 ![2024-05-01_21-57-19](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/2X/9/9894be5a97c0d21d8370879ddd9b5360234a219f.png)

我们可以把这个参数从编译环境中删除。
