我在我的项目中实现了 Blob 错误,并且它不断地给我一个以下代码归档日期的错误。
我需要做的是排除为 createTime 和 UpdateTime 字段生成 getter 和 setter。 因为我要克隆日期对象。
@Getter
@Setter
@MappedSuperclass
public class BaseErrorMessageDto implements Serializable {
@Getter(AccessLevel.PRIVATE)
private Date createTime;
@Getter(AccessLevel.PRIVATE)
private Date updateTime;
public Date getCreateTime() {
return (Date) createTime.clone();
}
public Date getUpdateTime() {
return (Date) updateTime.clone();
}
}
出现以下错误
May expose internal representation by incorporating reference to mutable object This code stores a reference to an externally mutable object into the internal representation of the object. If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.
我需要做的是排除为 createTime 和 UpdateTime 字段生成 getter 和 setter。
最佳答案
我认为它显示错误,因为您在字段中设置了私有(private)访问级别。 尝试在克隆时不要设置访问级别,否则会出现问题。
关于java - 如何忽略从java中的lombok生成一个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60069262/