我使用了 eclipse 的 lombok.jar 安装程序,它修改了我的 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
[email protected]/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 类都无法编译,因为 eclipse 不知道构建器、getter、setter 或构造函数
我的 eclipse 基目录中有 lombok.jar。
我通过双击 eclipse.exe 来运行 eclipse
这是最简单的示例类
@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;
}
如果我在命令行上运行maven,它会生成正确的代码(我使用反编译器来查看这一点)
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;
}
但是无论在哪里使用它,我都会遇到编译错误
ClientAccount 类型的 getClientId() 方法未定义第 43 行 Java 问题
或
ClientAccount 类型的方法 builder() 未定义第 12 行 Java 问题
编辑我刚刚更新到 lombok 版本 1.18.34,它现在出现在“关于”框中,但在尝试使用这些生成的方法的任何地方仍然收到错误
lombok 当前版本是 v1.18.34。你应该安装它;我们修复了一些听起来与您遇到的情况非常相似的问题。
如果您已完成此操作但仍然看到错误,请确保运行项目清除所有内容。或者关闭并重新打开所有项目。