Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

location of lombok.config file in java project

@AllArgsConstructor(suppressConstructorProperties = true) shows following error in eclipse :

This deprecated feature is no longer supported. Remove it; you can create a lombok.config file with 'lombok.anyConstructor.suppressConstructorProperties = true'.

I created this file , but the errors are not going away after commenting the @AllArgsConstructor line.

Can somebody please help on where to place this file exactly - I tried keeping in project root as well as src folder, but it did not work even after cleaning the project in eclipse? Do we need to do any specific action for the changes in lombok.config to reflect, like we have to restart eclipse after installing lombok.

I am using lombok version 1.16.18 , tried 1.14.4 version also, but same issue.

like image 756
immu Avatar asked Jan 05 '18 09:01

immu


People also ask

Where does Lombok config go in spring boot?

I put lombok. config in the project root directory of my Spring Boot project and it works fine. I put the file under src/main/java ; that fixed the problem.

How do I import Lombok into project?

Go to File > Settings > Plugins. Click on Browse repositories... Search for Lombok Plugin. Click on Install plugin.

How do I add a Lombok jar to my project?

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 show in the picture below, install and quit the installer and restart eclipse.

What is Lombok library in Java?

Project Lombok is a java library tool that is used to minimize/remove the boilerplate code and save the precious time of developers during development by just using some annotations. In addition to it, it also increases the readability of the source code and saves space.


2 Answers

According to lombok You can create lombok.config files in any directory and put configuration directives in it.
These apply to all source files in this directory and all child directories.
So if you want to affect all your code put the lombok.config in your root directory.

In your lombok.config file specify

lombok.anyConstructor.suppressConstructorProperties=true

If true, lombok will not generate a @java.beans.ConstructorProperties annotation when generating constructors. This is particularly useful for GWT and Android development.

And in your class just use @AllArgsConstructor in that way :

@AllArgsConstructor
public class Simple {
    private String text;
    private int num;
}
like image 115
Daniel Taub Avatar answered Oct 22 '22 12:10

Daniel Taub


The lombok documentation is a little hazy on the location of lombok.config and it states

Usually, a user of lombok puts a lombok.config file with their preferences in a workspace or project root directory

I misunderstood this to mean the project root when it's actually the sources root. If using Maven or Gradle, you can put the file in src/main/java/lombok.config. You can reduce the packages for which the config applies by putting lombok.config in the package directory (eg src/main/java/com/foo/mypackage/lombok.config). Using the second approach it's possible to have different config for different packages

like image 31
lance-java Avatar answered Oct 22 '22 10:10

lance-java