Lpmbok configuration in Eclipse , Intellij and STS

How to configure Lombok in Intellij, Eclipse, and STS

Suresh

--

Lombok is a Java library widely used in most Java projects. The purpose of Lombok is we don’t have to write manual setter/getter and Constructor with argument/without argument. You can use this library in the Spring Boot application by providing the following artifact.

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

Your Spring Boot by default takes the supported version. If you are using any other maven based Java Project, you have to use the Lombok version. The intention of this Story is after adding the above artifact how to configure the Lombok in the Intellij, eclipse, and STS.

Lombok setup in Intellij

Setting up Lombok in Intellij is very easy. After adding the artifact still, your Inellij expects to create getter and setter manually in your Java file. To fix this issue, you need to install the Lombok plugin in your Intellij.

Go to the “File” menu and click the “settings” menu item from the File menu

Type “Lombok” in the search textbox as above in the screenshot, the Lombok plugin shows in the search result with the install button. In my case Lombok is already installed so, it shows “Installed” Click the install button and complete the installation. That's it you have completed the Lombok configuration. Restart the Intellij. Create a one sample class like below

@Data
public class UserDto {

private String emailId;
private String fullName;
}

Add @Data annotation in the class level as above in the code. try to access this setter and getter method in some other class like below.

public static void main(String[] args) {
UserDto userDto = new UserDto();
String emailId = userDto.getEmailId();
String fullName = userDto.getFullName()
}

If Lombok successfully configured, you don’t get any compilation error while accessing the getter method from UserDto class.

Configure Lombok in Eclipse and STS

Configuring Lombok in Eclipse, STS and any other Eclipse-based IDE is the same step we have to follow. This configuration is not straight forward as we have seen in Intellij. Add the following artifact in your Project.

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

Go to the location where the Lombok jar file is located in your Computer. Generally, you can see all jar files in your Maven local repository. In my computer, it is located on the following path.
C:\Users\ssure\.m2\repository\org\projectlombok
From the above path go to the following location. In my case, I need to go below the location.
C:\Users\ssure\.m2\repository\org\projectlombok\lombok\1.18.12
Since I am using 1.18.12, a folder created in the name of version number under that folder you can see the Lombok jar file. like below
lombok-1.18.12.jar
Open a command prompt in this location as in the below screenshot

Maven Lombok folder Location

Run the following java command in the above location as below

java -jar lombok-1.18.12.jar

After running the above java command, a popup window will appear as below in the screenshot. When you look at this screenshot, it says that can’t find any IDE on your computer. Click “ok” then.

Click the “Specify Location” Button, A browse popup window will appear where you need to select the location of your eclipse.exe in your computer (You can find the eclipse.exe in Eclipse installation location ) as in the below screenshot.

browse the popup window

select the “eclipse.exe” file then click the “Install/update” button as in the below screenshot.

Install/update

Once you click the install/update button, it will install the Lombok successfully in your eclipse and show the following message.

Installation completed

Then, click “Quite Installer”. That’s it you have done with Lombok configuration in your eclipse. The Exact same step you need to follow STS and all eclipse based IDE.

Restart your eclipse and create the following sample class in your Java Project and test it.

@Data
public class User {
private String name;
private String emailId;
}public static void main( String[] args )
{
User user = new User();
String name = user.getName();
String emailId = user.getEmailId();
}

If you are not getting any compilation error. you have successfully installed the Lombok in your Eclipse or STS IDE.

Thanks for reading this full Story. I will soon come up with some useful story

--

--