当前位置:
首页 >
行业知识 >
spring boot项目编译报错“exporting a package from system module java.base is not allowed with --release”
行业知识
spring boot项目编译报错“exporting a package from system module java.base is not allowed with --release”
2026-12-04 10:09:17
来源:互联网转载
文章目录
- 1.问题描述
- 1.1 环境
- 2.描述
- 2. 分析
- 2.1 不使用exporting
- 2.2 不使用--release
- 3.解决方案
- 3.1不使用exporting
- 3.2 不使用--release
1.问题描述
1.1 环境
- IDEA 2023.3
- JDK 21
- Spring boot 3.2.4
- maven-compiler-plugin 3.13.0
2.描述
今天在使用spring boot 3.2.4这个版本时,由于需要使用security包下面的类,因此需要导出相应模块。即:
()org.apache.maven.pluginsmaven-compiler-plugin3.13.021UTF-8true2121--add-exportsjava.base/sun.security.x509=ALL-UNNAMED
但是在进行Maven编译时,报了如下的错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project demo: 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]
2. 分析
exporting a package from system module java.base is not allowed with --release 报错信息很清楚,exporting module和–release不能同时使用,那么就只有两个选择了:
()- 不使用exporting
- 不使用–release
2.1 不使用exporting
这个还没有具体研究,应该有可以替代的依赖。
2.2 不使用–release
最先需要明白的是,我在什么地方使用了–release?
由于使用了spring boot parent的依赖
org.springframework.bootspring-boot-starter-parent3.2.4
该依赖当中又包含了
17 @ ${java.version} UTF-8 UTF-8maven.compiler.release这个参数便是引入了release的参数。那解决问题也很简单了,把这个参数去掉就好了。
3.解决方案
3.1不使用exporting
挖个坑
3.2 不使用–release
去掉这个参数,也很简单,只需要在pom文件当中覆盖这个参数的值:
21
这样就可以正常编译项目了,不会再报“exporting a package from system module java.base is not allowed with --release”错误了。
上一篇:服务器充电桩怎么用?
下一篇:泰兰德服务器怎么样?