前言
现在已经出了jdk17了,项目中还在使用jdk1.8
更新jdk为17时,发现编译代码出现这样的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project call-common: Fatal error compiling: java.lang.IllegalAccessErro
r: class lombok.javac.apt.LombokProcessor (in unnamed module @0x7d41aefd) 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 @0x7d41aefd -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :call-common
原因分析
编译出现这样的错误,是因为使用的lombok的版本较低(1.18.8),不兼容jdk17
可以通过这个地址查看当前版本的lombok支持哪个版本的jdk
https://projectlombok.org/changelog
解决
将代码引用的lombok版本改为1.18.22,编译就不会报错了。