In this article, we will discuss how to use Lombok in Java maven project and also we will discuss how to set up or install Lombok in Eclipse IDE.
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.
Since Lombok library is not required at the time of application execution, the appropriate scope is provided.
You can start using Lombok in maven project in Eclipse IDE. To learn more, check out the Complete Project Lombok Tutorial.
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
Follow below steps to setup Lombok in your Java projects:
- 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)
Here are the installation steps to setup eclipse for Windows:
- 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.
Comments
Post a Comment
Leave Comment