日々精進

新しく学んだことを書き留めていきます

ビルド時に「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.」警告が出る

メッセージは以下。

Warning:(11, 1) java: 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.

原因はlombokの@Dataを親クラス・子クラスの両方に付けていること。 @Dataが生成するequals/hashCode実装はsuperを呼ばないので、親クラスのフィールドを無視しちゃうけどいいの?という警告。 基本的には @EqualsAndHashCode(callSuper=true) を子クラスに付ければいいと思う。

参考: