[英]Eclipse reporting "the value of the field is not used" warning even though Lombok enable
I have 2 classes in a Eclipse project.我在 Eclipse 项目中有 2 个课程。
package com.example;
import lombok.Getter;
import lombok.experimental.Accessors;
@Accessors(fluent = true)
@Getter
public class MyBean {
private String value = "aaa";
}
package com.example;
public class MyClass {
public static void main() {
System.out.println(new MyBean().value());
}
}
After building, Eclips reports "the value of the field value is not used"
for MyBean
class and "The method value() is undefined for the type MyClass"
even though Eclipse's content assist shows MyBean#value()
method, there are no warnings before building, and compilation, execution both are finished successfully.构建后,Eclips 报告
MyBean
class "the value of the field value is not used"
和"The method value() is undefined for the type MyClass"
即使 Eclipse 的内容辅助显示MyBean#value()
方法,也没有警告在构建和编译之前,执行都已成功完成。 So I guess Lombok works properly and the problem is Eclipse doesn't recognize Lombok.所以我猜 Lombok 工作正常,问题是 Eclipse 无法识别 Lombok。
Here are what I tried and found.这是我尝试和发现的。
Any ideas?有任何想法吗?
Finally, the problems are solved by just creating new project and moving all sources and resources to it.最后,只需创建新项目并将所有资源和资源移至该项目即可解决问题。 It seems that Eclipse's project configurations were broken I don't know why.
似乎Eclipse的项目配置被破坏了我不知道为什么。
I install lombok on eclipse(java -jar lombokxxxx.jar) and the problem disapear.我在 eclipse(java -jar lombokxxxx.jar) 上安装了 lombok 并且问题消失了。
Lombok API Configuration龙目岛 API 配置
Note: Lombok version may change.注意:龙目岛版本可能会更改。 Present we are using 1.18.24
目前我们正在使用 1.18.24
Lombok configuration window
will open > Click on Specify location
button Lombok configuration window
将打开 > 单击Specify location
按钮Install / Update
button in Lombok configuration window
Lombok configuration window
中的Install / Update
按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.