问题
I've added Lombok maven repository in my project and successfully use the Lombok annotations. And I tried to access the setter and getter methods from another class but couldn't access those methods. I'm using spring Boot version 2.1.1 and STS. Here is my simple code snippet.
@Entity
@Table(name = "role")
//@Data
@ToString
public class Role {
@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="role_id")
private int id;
@Column(name="role")
@Getter @Setter(AccessLevel.PUBLIC)
private String role;
}
回答1:
You should install it in your STS. Follow the instructions:
Double-click lombok.jar (downloadable from here, or from your maven repository; it's the same jar). This starts the eclipse installer which will find eclipse (and eclipse variants as listed above), and offers to install lombok into these eclipse installations. The same tool can also uninstall lombok:
You can check if your eclipse installation is lombok-enabled in eclipse's about dialog. The lombok version will be listed at the end of the copyright text:
Source: https://projectlombok.org/setup/eclipse
Hope it helps.
来源:https://stackoverflow.com/questions/54018276/how-to-access-getter-and-setter-methods-using-lombok