How to get rid of InvalidClassException SerialVers

2019-04-27 13:10发布

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条回答
我只想做你的唯一
2楼-- · 2019-04-27 14:03

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;
查看更多
登录 后发表回答