How to access getter and setter methods using Lombok? [duplicate]

大兔子大兔子 提交于 2021-02-09 06:57:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!