Thursday, 16 May 2019

Get rid of boilerplate code (setters and getters) - Lombok

Maven dependency

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.8</version>
</dependency>

Code template

@Getter @Setter @RequiredArgsConstructor @ToString
public class User {
    private final String name;
    private int age;
}

Install Lombok in eclipse

Go to the directory where lombok.jar sits. (e.g. /Users/msun/.m2/repository/org/projectlombok/lombok/1.18.8/)


java -jar lombok-1.18.8.jar



No comments:

Post a Comment