springboot:2.7.2 升级java8到java17 报错排查
- 修改java版本到17
<properties>
<java.version>17</java.version>
...
</properties>
- 执行
mvn clean compile
, 但是报错如下
[22:17:11] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project majj-blog: Compilation failure -> [Help 1]
- 开启详细日志输出
mvn clean compile -e -X
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project majj-blog: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x39d8240b) 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 @0x39d8240b -> [Help 1]
- 从报错日志可以看出是lombok导致的, 查询官网调整到合适版本
https://projectlombok.org/changelog)
从changelog可以看到, 理论上升级到 v1.18.22以上都是可以的.
- 修改项目pom.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
- 再次执行
mvn clean compile -e -X
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------