最近在搭建一个demo项目。
基于老项目来配置,结果发生了一些错误。
java
lombok 方法引用无效 找不到符号
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile)
on project rc-platform: Resolution of annotationProcessorPath dependencies failed:
For artifact {org.projectlombok:lombok:null:jar}: The version cannot be empty. -> [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] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile)
on project rc-platform: Fatal error compiling: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member
field 'com.sun.tools.javac.tree.JCTree qualid' -> [Help 1]
[ERROR]
解决办法:
使用最新的 lombok 版本.
例如:
xml
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<!-- 在SpringBoot 的打包阶段不需要lombok-->
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
按照 stackoverflow 的说法:
The culprit is Lombok. The minimal Lombok version compatible with JDK 21 is 1.18.30.
链接: