Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Lombok is an opensource project that reduces boiler plate code in the Java Pojo's by using annotations in the class. The main advantage of Lombok is to get rid of generating getters & setters (although the IDE generates it).

The source code can be found in GitHub.

Lombok in Action:

Add the dependency in pom.xml

lombok maven
<dependency>
   <groupId>org.projectlombok</groupId>
   <artifactId>lombok</artifactId>
   <version>1.18.2</version>
   <scope>provided</scope>
</dependency>
lombok example
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Book {
	
	private int id;
	private String name;
	private String author;
	
}

Other useful Annotations:

@ToString

@Builder

@NoArgsConstructor

@RequiredArgsConstructor

@EqualsAndHashCode and lot more ..


IDE's like Eclipse & IntelliJ does not detect the lombok annotations by default.

Lombok in IntelliJ:

Go to File → Settings → Plugins → Browse Repositories. Search for lombok.

Lombok in Eclipse:

Download Lombok and run the Jar. Specify the eclipse location and click Install.

Check the eclipse installation of lombok in About eclipse.


Other useful Reference:

How Lombok Works

Lombok Features

Delombok

  • No labels