lombok版本报错问题java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module

lombok版本报错问题

记录一个项目部署时遇到的问题,我本地采用的JDK8的版本,然后我的服务器采用的是JDK17,然后在用maven进行打包的时候,发现package失败。

复现

我在本地采用的lombok版本是1.18.12,然后运行打包是没有问题的,然后再服务器上报错

<dependency>
     <groupId>org.projectlombok</groupId>
     <artifactId>lombok</artifactId>
     <version>1.18.12</version>
     <scope>provided</scope>
</dependency>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project comment-system:
 Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x6dcbbb49) cannot access
 class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) 
because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x6dcbbb49 -> [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/MojoExecutionException

官网上JDK9+推荐我们使用1.18.24版本

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xOAPCIZa-1670466931228)(C:\Users\DY\AppData\Roaming\marktext\images\2022-12-08-10-32-52-image.png)]

因此我们将依赖更改为1.18.24, 然后打包就成功了

<dependency>
     <groupId>org.projectlombok</groupId>
     <artifactId>lombok</artifactId>
     <version>1.18.24</version>
     <scope>provided</scope>
</dependency>

在这里插入图片描述

posted @ 2022-12-08 10:38  Leo哥coding~  阅读(1218)  评论(0编辑  收藏  举报  来源