IDEA solves Lombok warnings in batches, a must-have skill for developers!

problem background

When using Lombok's @Data annotation, because a public Base base class is encapsulated, the following warning prompt will always be prompted:

Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '(callSuper=false)' to your type. Check information: Provide Lombok annotation 
 general examine.

What are the specific problems?

 Generating equals/hashCode implementation but without a call to superclass. That is, the attributes of the parent class will not be added automatically.

It's a bit off-putting.

Solution

The suggestion given is to directly add the following annotations to solve 

@EqualsAndHashCode(callSuper = true)

The problem can be solved, but each one has to be changed, especially for relatively large projects such as microservices. It is much more troublesome to modify.

Is there any good way, this really exists.

Now you can create a lombok.config file directly in the root directory or src directory of the project.

Then add two lines of code inside and it can be removed.

config.stopBubbling=true
lombok.equalsAndHashCode.callSuper=call

Then look at the code and find that the wavy line of @Data is gone.

Summarize

According to Ali's coding specification, if equals is rewritten, the hashCode method must be rewritten. Failure to rewrite may cause problems with certain hash-based data structures (such as HashSet, HashMap, etc.).

So it's best to deal with some warnings if you can deal with them

Guess you like

Origin blog.csdn.net/m290345792/article/details/132716932