问题
I had saved one java object in the Database and then after few days I changed my jre version. Now when i tried to read that same object I am getting following exception:
Exception in thread "main" java.io.InvalidClassException:
SerializeMe; local class incompatible: stream classdesc
serialVersionUID = -6377573678240024862, local class serialVersionUID = -8204757486033751616
How can I get rid of this,how can I get the saved object?
please help me.
回答1:
If you can affect source code of this class and JRE was only thing that changed, most likely you can still deserialize object that was serialized by older JVM. Just define following field in class to be deserialized:
private static final long serialVersionUID = -6377573678240024862L;
来源:https://stackoverflow.com/questions/13599217/how-to-get-rid-of-invalidclassexception-serialversionuid