2

I use Lombok on Hibernate entities, and have inheritance:

@MappedSuperclass
@Data
public class BaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private Boolean enabled;
    public BaseEntity() {
        enabled = true; 
    }
}

@Entity
@Data
public class Event extends BaseEntity {
    private String name;
    private LocalDateTime start;
    private LocalDateTime end;
    private Boolean isTaxable;
}

Eclipse warns on child @Data:

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 '@EqualsAndHashCode(callSuper=false)' to your type.

as mentioned here Warning equals/hashCode on @Data annotation lombok with inheritance

I can use

lombok.equalsAndHashCode.callSuper = call

how can I use this property in spring application.properties file? Should I create lombok.config file near the application.properties and put it there instead?

I tried to add it to application.properties

lombok.equalsAndHashCode.callSuper = call

but Eclipse says this property unknown and Warning on child class @Data annotation still present.

P_M
  • 2,723
  • 4
  • 29
  • 62

1 Answers1

4

As lombok is an annotation processor, it does its work during compilation. Thus, everything you want to configure in lombok has to be present when building your project.

You have to put all lombok configuration options into a file named lombok.config. This file is typically placed in your project root folder. For details, see the lombok documentation. (Note that this file will not be contained in the built artifact, e.g. the JAR file.)

You cannot configure lombok at runtime (e.g., using an application.properties).

Jan Rieke
  • 7,027
  • 2
  • 20
  • 30
  • Though Eclipse see getters and setters, @Slf4j annotations and so, before compilation. I thought Eclipse Lombok plugin should also know about properties set in lombok.config file. Or it is not? – P_M Sep 07 '18 at 12:46
  • 1
    Eclipse should recognize it. You may have to do a Clean/Recompile for the settings to take effect. Make sure you have the current version 1.18.2 of the lombok plugin installed in Eclipse (see the "About Eclipse" dialog). If this does not help and the warning persists in Eclipse, but there is definitely no warning when compiling with maven or gradle, please file a bug at https://github.com/rzwitserloot/lombok/issues, with a description how to reproduce. – Jan Rieke Sep 07 '18 at 13:57
  • When I use The Lombok Gradle Plugin the _lombok.config_ file is overriden by the plugin deleting my config. – Hector Nov 06 '19 at 14:30