将项目打包时,控制台报错,信息如下:

class lombok.javac.apt.LombokProcessor (in unnamed module @0x61bfc9bf) 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 @0x61bfc9bf

这是lombok版本过低导致,报错版本pom依赖:

<!--Lombok -->
<dependency>
	<groupId>org.projectlombok</groupId>
	<artifactId>lombok</artifactId>
	<version>1.18.16</version>
</dependency>

将1.18.16改为1.18.24改为高版本:

<!--Lombok -->
<dependency>
	<groupId>org.projectlombok</groupId>
	<artifactId>lombok</artifactId>
	<version>1.18.24</version>
</dependency>

再次打包,成功:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ zhufeng-base-api ---
[INFO] Building jar: /Users/zhufeng/workplace/zhufeng-base-api-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ zhufeng-base-api ---
[INFO] Installing /Users/zhufeng/workplace/zhufeng-base-api-1.0-SNAPSHOT.jar
[INFO] Installing /Users/zhufeng/workplace/zhufeng-base-api-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.261 s
[INFO] Finished at: 2022-08-30T10:28:44+08:00
[INFO] ------------------------------------------------------------------------

有时候pom中没有没指定lombok版本,使用默认版本时也需要注意检查默认的版本号

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐