本文介绍了错误:本地类不兼容:流classdec serialversionUID = ....,本地类serialversionUID =的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可序列化的Java类,当我添加以下方法之一。我得到这个错误本地类不兼容:类classdec serialversionUID = ...,本地类serialversionUID = ...
$
public HashMap< Long,BookIndex> getBookIndexMap(){
return bookIndexMap;
}
public String getDataFileName(){
return dataFileName;
$ / code $
这是什么原因造成的?怎样才能纠正?
解决方案这篇文章可能会有帮助: $ b
通过改变类的方法签名,以前的序列化表单是不兼容的,除非这些类具有相同的serialVersionUID。 p>
I have a serializable java class and when I add either of the following methods. I get this error
" local class incompatible: stream classdec serialversionUID= ...., local class serialversionUID=..."
added methods:
public HashMap<Long, BookIndex> getBookIndexMap() {
return bookIndexMap;
}
public String getDataFileName() {
return dataFileName;
}
what is causing this and how can I correct it?
解决方案 This article may be helpful:
http://lingpipe-blog.com/2010/05/04/upgrading-java-classes-backward-compatible-serialization/
By changing the class's method signatures, previous serialized forms are incompatible unless the classes have the same serialVersionUID.
这篇关于错误:本地类不兼容:流classdec serialversionUID = ....,本地类serialversionUID =的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!