gpt4 book ai didi

java - 不同的java版本会创建不同的serialVersionUID吗?

转载 作者:搜寻专家 更新时间:2023-11-01 03:34:02 25 4
gpt4 key购买 nike

我已将我的 Java 版本从 1.6 更新到 1.8。当我尝试在 weblogic (12c) 中部署我的项目时,出现以下错误。

java.io.InvalidClassException: org.springframework.beans.PropertyAccessException; local class incompatible: stream classdesc serialVersionUID = -5171479712008793097, local class serialVersionUID = 736080306599024264

我是否需要重新生成 serialVersionUID ,它是使用 java 1.6 版创建的?

请帮忙

谢谢,

拉吉

最佳答案

是的,编译器版本很重要。 Serializable Javadoc 说(部分)

If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization.

关于java - 不同的java版本会创建不同的serialVersionUID吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37253009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com