java - EntityClass 中的 LocalDate 扰乱了 sonarQube
问题描述
我有带有 LocalDate 的实体类,实体类本身根据 JPA 规范实现可序列化。
到目前为止一切正常,但 SonarQube 现在抱怨:
Local Date is a Value type Class and should not be serialized.
它建议删除该字段或使其成为瞬态 - 在这种情况下,这两种方法都不起作用,因为我们需要将这些字段持久化到数据库或一些内存中存储。
public class User implements Serializable{
//other attributes
@Column(name = "UPDATED_DATE")
private LocalDate updatedDate;
}
谁能建议我们如何解决这个问题?
谢谢
解决方案
如文档中所述, https://sonarcloud.io/coding_rules?open=squid%3AS3437&rule_key=squid%3AS3437
您可以放在字段transient
前面,date
也可以像这样抑制警告:
@SuppressWarnings("squid:S3437") //LocalDate is serializable
public class User implements Serializable{..}
推荐阅读
- php - gammu 不通过 PHP 命令行发送特殊字符
- cucumber - 如何在黄瓜钩子方法中读取标签的值
- git - 无论git历史记录中的分支如何,如何检查最新提交?
- javascript - 固定 X 轴比例且从不更改 amcharts
- react-native - 换屏时强制卸载
- javascript - 将 ID 令牌发送到 firebaseui 中的 signInSuccessUrl
- r - 如何计算大型数据集中出现的次数
- cloud-foundry - cf push 和 cf restage 的区别
- css - 如何在 Internet Explorer 中为实时网站保存开发人员工具中的 css 更改
- c# - 我想将图像和文本放入列表框项(C# wpf)