lombok注解@Data使用在繼承類上時出現警告Generating equals/hashCode implementation but without a call to superclass, even though this class ...


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.

解決方法:

1)在子類上面直接加

@EqualsAndHashCode(callSuper = true)

 這個方法在每個子類上都要加入。

2)在實體類的目錄里加入一個config

lombok.config內容如下:

config.stopBubbling=true

lombok.equalsAndHashCode.callSuper=call

以配制文件的形式,可以不用在子類上加入,全局有效。 

 

 

pom.xml還要加入下面的

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
          <source>1.8</source>
          <target>1.8</target>
      </configuration>
</plugin>

從單詞的意思來看就是指定編譯jdk的版本,以及編譯了。

 參考:

https://blog.csdn.net/feinifi/article/details/85275280


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM