Eclipse 24-6与Lombok插件兼容问题:编译报错无法识别生成方法
Eclipse 2024-06配置Lombok后注解不生效问题
配置详情
通过Lombok jar安装器配置Eclipse 2024-06,已自动修改eclipse.ini文件,配置内容如下:
-startup plugins/org.eclipse.equinox.launcher_1.6.800.v20240513-1750.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.2.1000.v20240507-1834 -product org.eclipse.epp.package.jee.product -showsplash org.eclipse.epp.package.common --launcher.defaultAction openFile --launcher.appendVmargs -vm plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_21.0.3.v20240426-1530/jre/bin -vmargs -javaagent:C:/Users/me/eclipse/2024-03/lombok.jar -Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclientjava -Dosgi.requiredJavaVersion=21 -Dosgi.instance.area.default=@user.home/eclipse-workspace -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true -Declipse.e4.inject.javax.warning=false -Dsun.java.command=Eclipse -Xms256m -Xmx2048m -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -Djava.security.manager=allow
Lombok jar已放置在Eclipse根目录,通过双击eclipse.exe启动程序;已升级至Lombok 1.18.34版本,插件已在Eclipse关于页面显示。
问题现象
所有带有Lombok注解的类编译失败,Eclipse无法识别注解生成的builder、getter、setter或构造方法。
示例实体类代码
@Builder @AllArgsConstructor @Data public class ClientAccount { @Size(max = 30) private String accountName; @Size(max = 50) private String accountReference; @NotNull @Size(max = 32) private String clientId; @NotNull @Size(max = 64) private String clientSecretKey; private LocalDateTime keyLastUpdated; }
编译报错示例
The method getClientId() is undefined for the type ClientAccount(第43行)The method builder() is undefined for the type ClientAccount(第12行)
验证情况
- 通过命令行执行Maven编译正常,反编译生成的class文件确认已正确生成builder方法、全参构造方法及所有属性的getter/setter,反编译代码如下:
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import java.time.LocalDateTime; import lombok.Generated; public class ClientAccount { @Size( max = 30 ) private String accountName; @Size( max = 50 ) private String accountReference; @NotNull @Size( max = 32 ) private String clientId; @NotNull @Size( max = 64 ) private String clientSecretKey; private LocalDateTime keyLastUpdated; @Generated public static com.pancredit.equifax.model.ClientAccount.ClientAccountBuilder builder() { return new com.pancredit.equifax.model.ClientAccount.ClientAccountBuilder(); } @Generated public ClientAccount(final String accountName, final String accountReference, final String clientId, final String clientSecretKey, final LocalDateTime keyLastUpdated) { this.accountName = accountName; this.accountReference = accountReference; this.clientId = clientId; this.clientSecretKey = clientSecretKey; this.keyLastUpdated = keyLastUpdated; } @Generated public String getAccountName() { return this.accountName; } @Generated public String getAccountReference() { return this.accountReference; } @Generated public String getClientId() { return this.clientId; } @Generated public String getClientSecretKey() { return this.clientSecretKey; } @Generated public LocalDateTime getKeyLastUpdated() { return this.keyLastUpdated; } @Generated public void setAccountName(final String accountName) { this.accountName = accountName; } @Generated public void setAccountReference(final String accountReference) { this.accountReference = accountReference; } @Generated public void setClientId(final String clientId) { this.clientId = clientId; } @Generated public void setClientSecretKey(final String clientSecretKey) { this.clientSecretKey = clientSecretKey; } @Generated public void setKeyLastUpdated(final LocalDateTime keyLastUpdated) { this.keyLastUpdated = keyLastUpdated; } }
- 已在项目设置中开启注解处理功能
内容的提问来源于stack exchange,提问作者WendyG
相关产品推荐
相关产品推荐

