@Data @EqualAndHashCode
时间: 2023-08-17 22:13:05 浏览: 177
@EqualsAndHashCode(callSuper=true)注解的作用是在使用@Data注解时,确保在生成的equals()和hashCode()方法中包含父类的属性,避免因为属性不一致而导致错误的相等判断。\[1\]这个注解可以解决在派生类中使用@Data注解可能出现的问题。\[2\]\[3\]所以,在使用@Data注解时,建议同时加上@EqualsAndHashCode(callSuper=true)注解,以确保正确的相等判断。
#### 引用[.reference_title]
- *1* [SpringBoot中的@EqualsAndHashCode注解与@Data注解](https://blog.csdn.net/gdkyxy2013/article/details/104769897)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [@EqualsAndHashCode()和@Data注解详解](https://blog.csdn.net/jiangyyyeff/article/details/122556547)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [注解@Data与@EqualsAndHashCode的爱恨情仇](https://blog.csdn.net/qq_33188180/article/details/122590629)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文