EI_EXPOSE_REP是spotbugs,findbugs里通過代碼分析拋出來的代碼安全性問題,主要表示在一個Date型別的欄位在進行@Getter注解時,沒有檢查它是否為空,這塊我們有兩種解決方案,第一種是手寫Date型別的欄位的Getter方法;第二種是安裝com.google.code.findbugs:findbugs包,然后使用它的@SuppressFBWarnings注釋,把這種問題忽略,我們介紹一下這兩種方法,
第一種
重寫它的setter方法
public void setBillDate(Date billDate) {
this.billDate = billDate != null ? new Date(billDate.getTime()) : null;
}
第二種
使用參考findbug包
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>3.0.1</version>
</dependency>
在物體上添加SuppressFBWarnings注解即可
@Data
@SuppressFBWarnings(value = https://www.cnblogs.com/lori/p/{"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.uj5u.com/qita/506.html
標籤:其他
上一篇:nginx~ssl的配置
下一篇:銀聯支付介面除錯
