Lombok is a library used for reducing the boilerplate code from Java source code.
Boilerplate code is a typical source code that cannot be omitted by the language specification. Basically, the boilerplate code does not have a specific logic hence it becomes redundant code in implementation.
Following are the typical Boilerplate source code in Java language.
- getter/setter methods for accessing the member variables
- equals/hashCode methods
- toString methods
- Constructors
- Closing process of resources (input and output stream, etc.)
- Generation of the logger instance
Add Project Lombok Dependency to Maven Project
- Create a simple maven project using - How to Create a Simple Maven Project in Eclipse article.
- Add the below dependency in your maven project pom.xml file:
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
Adding the Lombok Plugin in IDE (Eclipse)
- Downloaded jar from https://projectlombok.org/download or use the jar which is downloaded from your maven build.
- Execute command in terminal: java -jar lombok.jar
- This command will open window as shown in the picture below, install and quit the installer and restart eclipse.
You can start using Lombok in maven project in Eclipse IDE. To learn more, check out the Complete Project Lombok Tutorial.
Project Lombok Articles
Continue Learning with Java Guides
Want to take your programming skills to the next level? Explore my practical Udemy courses on Java, Spring Boot, Microservices, Full-Stack Development, Docker, and Generative AI. You can also follow my structured learning roadmaps to become a professional developer.
By Ramesh Fadatare - Udemy Instructor Partner
Comments
Post a Comment
Leave Comment