为什么无法反序列化但是我已经序列化了这个 Container 类使用serialVersionUID = 75264711556228L;
public class Container implements Serializable {
private static final long serialVersionUID = 75264711556228L;
public boolean isFromLocalCollect=false;
public boolean isFromLocalCollect=false;
public void setFromLocalCollect(boolean isFromLocalCollect) {
this.isFromLocalCollect=isFromLocalCollect;
}
public boolean getFromLocalCollect() {
return this.isFromLocalCollect;
}
}
现在,在使用名称 container.ser 进行序列化后,我在 Container 类中添加了一个 setter 和 getter 方法,例如:
public class Container implements Serializable {
private static final long serialVersionUID = 75264711556228L;
public boolean isFromLocalCollect=false;
public boolean isFromLocalCollect=false;
public void setFromLocalCollect(boolean isFromLocalCollect) {
this.isFromLocalCollect=isFromLocalCollect;
}
public boolean getFromLocalCollect() {
return this.isFromLocalCollect;
}
public boolean isFromLocalCollect2=false;
public void setFromLocalCollect2(boolean isFromLocalCollect2) {
this.isFromLocalCollect2=isFromLocalCollect2;
}
public boolean getFromLocalCollect2() {
return this.isFromLocalCollect2;
}
}
然后我尝试使用更改的项目名称来反序列化对象,但未能反序列化并且我得到如下错误:
java.io.InvalidClassException: cvb.db.PbDb; local class incompatible: stream classdesc serialVersionUID = -444070985558173412, local class serialVersionUID = 4350771162641935418