Setup Lombok with Spring Boot

 Lombok is a Java library that takes care of generating lot of this boiler plate code for the developers.

Lombok works by plugging into your build process and hooking into Java byte-code generation stage, to add required code based on your specifications. Lombok uses annotations to identify which piece of code needs to be auto generated.

Adding Lombok to any project is very simple. You simply have to include the  Lombok package in your build path. 

If you are using Spring boot, Lombok version will be resolved for you by Spring.

Maven pom.xml



Lombok Sample

public class Person {
    private String name;
    private int age;

Unit Test

class PersonTest {

    public void data_annotation() {
        Person person = new Person();
        person.setName("David Hoff");

        Assertions.assertEquals("David Hoff", person.getName());
        Assertions.assertEquals(25, person.getAge());

The entire sample code can be found on Github


Post a Comment