EI_EXPOSE_REP是spotbugs,findbugs里通过代码分析抛出来的代码安全性问题,[email protected],没有检查它是否为空,这块我们有两种解决方案,第一种是手写Date类型的字段的Getter方法;第二种是安装com.google.code.findbugs:findbugs包,[email protected],把这种问题忽略,我们介绍一下这两种方法。
第一种
重写它的getter方法
public void setBillDate(Date billDate) {
this.billDate = billDate != null ? new Date(billDate.getTime()) : null;
}
第二种
使用引用findbug包
com.google.code.findbugs
findbugs
3.0.1
在实体上添加SuppressFBWarnings注解即可
@Data
@SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"}, justification = "I prefer to suppress these FindBugs warnings")
public abstract class BaseEntity> extends Model {
private Date createTime;
private String createUser;
private Date updateTime;
private String updateUser;
}
再进行spotbugs:spotbugs时,这个错误就没有了。
原文:https://www.cnblogs.com/lori/p/13601262.html