Lombok does not create getter and setter methods after using @Data

天涯浪子 提交于 2021-01-29 03:01:47

问题


I have gradle spring boot project and I added Lambok dependency in build.gradle. I created one model class and want to use lombok. I have added @Data annotation but still setter and getter methods are not generated. Sample code :

import lombok.Data;

@Data
public class TestLambok {
    private int id;
    private String name;
    private String summary;

}

回答1:


For use Lombok Plugin, you need the following steps (at least on IntelliJ):

  • Install Lombok Plugin
  • Enabling Annotation Processing
  • Restart IDE

For more information you can read this post: https://www.baeldung.com/lombok-ide




回答2:


Install the Lombok plugin first then you can use the @Data annotation. Please note that you won't physically see the getters, setters and toString() appear in your class aktjouy Lombok will create it



来源:https://stackoverflow.com/questions/60596222/lombok-does-not-create-getter-and-setter-methods-after-using-data

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