【发布时间】:2015-01-27 16:16:33
【问题描述】:
我有一个使用@EqualsAndHashCode 扩展父类的类。 Lombok 1.16.0 和 Java 8 出现编译错误
@EqualsAndHashCode(doNotUseGetters = true, of = { "propertyA", "propertyB" })
public class Parent {...}
@EqualsAndHashCode(callSuper = true, doNotUseGetters = true, of = { "propertyC", "propertyD" })
public class Child extends Parent {...}
错误是……
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project granger: Compilation failure
[ERROR] /Users/sarah/src/main/java/com/xxx/Child.java:[26,1] canEqual(java.lang.Object) in com.xxx.Child cannot override canEqual(java.lang.Object) in com.yyy.Parent
[ERROR] attempting to assign weaker access privileges; was public
有没有关于我滥用的继承和@EqualsAndHashCode 和 Lombok 的最佳实践?或者有什么办法?
【问题讨论】: