简体   繁体   中英

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

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;

}

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

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

Im using visual studio code. There is an extension called "Lombok Annotations Support for VS Code".

Installing this allowed the auto generated methods to show when querying the properties of the object

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM