Below is my object class:
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MyObject {
public Long empID;
public String firstName;
public String lastName;
public MyObject(Long empID, String firstName, String lastName) {
super();
this.empID = empID;
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public String toString() {
return "MyObject [empID=" + empID + ", firstName=" + firstName + ", lastName=" + lastName + "]";
}
}
I tried to use and create an object in another class as below:
MyObject myobj = new MyObject();
After typing myObj
, I don't see getEmpId()
or getfirstName()
as if I had written explicit getters and setters.
Kindly suggest a solution if I am missing anything here.
我能够通过从此链接下载 Lombok 插件来解决此问题,并且它有效。
If you are using Eclipse or one of its offshoots(I am using STS 4.5.1.RELEASE
), all that you need to do is:
In build.gradle, you ONLY need these 2 "extra" instructions:
dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' }
Right-click on your project > Gradle > Refresh Gradle Project. The lombok-"version".jar
will appear inside your project's Project and External Dependencies
Right-click on that lombok-"version".jar
> Run As > Java Application (similar to double-clicking on the actual jar or running java -jar lombok-"version".jar
on the command line.)
A GUI will appear, follow the instructions and one of the thing it does is to copy lombok.jar
to your IDE's root.
The only other thing you will need to do(outside of the GUI) is to add that lombok.jar
to your project build path
That's it!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.