eclipse中经常提示:TheserializableclassAddUserFormdoes错误解决方法
2013-07-18 13:36
309 查看
eclipse中经常提示:
The serializable class AddUserForm does not declare a static final serialVersionUID field of type long
查了一下,如下说:
serialVersionUID 用来表明类的不同版本间的兼容性.如果你修改了此类, 要修改此值. 否则以前用老版本的类序列化的类恢复时会出错.
可以利用JDK的bin目录下的serialver.exe工具产生这个serialVersionUID
对于Test.class,执行命令: serialver Test
为了在反序列化时,确保类版本的兼容性,最好在每个要序列化的类中加入private static final long serialVersionUID这个属性,具体数值自己定义。这样,即使某个类在与之对应的对象已经序列化出去后做了修改,该对象依然可以被正确反序列 化。否则,如果不显示定义该属性,这个属性值将由JVM根据类的相关信息计算,而修改后的类的计算结果与修改前的类的计算结果往往不同,从而造成对象的反 序列化因为类版本不兼容而失败。
不显示定义这个属性值的另一个坏处是,不利于程序在不同的JVM之间的移植。因为不同的编译器实现的该属性值的计算策略可能不同,从而造成虽然类没有改变,但是因为JVM不同,依然会有因类版本不兼容而无法正确反序列化的现象出现。
可以用Ctrl+1进行自动修正.
The serializable class AddUserForm does not declare a static final serialVersionUID field of type long
查了一下,如下说:
serialVersionUID 用来表明类的不同版本间的兼容性.如果你修改了此类, 要修改此值. 否则以前用老版本的类序列化的类恢复时会出错.
可以利用JDK的bin目录下的serialver.exe工具产生这个serialVersionUID
对于Test.class,执行命令: serialver Test
为了在反序列化时,确保类版本的兼容性,最好在每个要序列化的类中加入private static final long serialVersionUID这个属性,具体数值自己定义。这样,即使某个类在与之对应的对象已经序列化出去后做了修改,该对象依然可以被正确反序列 化。否则,如果不显示定义该属性,这个属性值将由JVM根据类的相关信息计算,而修改后的类的计算结果与修改前的类的计算结果往往不同,从而造成对象的反 序列化因为类版本不兼容而失败。
不显示定义这个属性值的另一个坏处是,不利于程序在不同的JVM之间的移植。因为不同的编译器实现的该属性值的计算策略可能不同,从而造成虽然类没有改变,但是因为JVM不同,依然会有因类版本不兼容而无法正确反序列化的现象出现。
可以用Ctrl+1进行自动修正.
相关文章推荐
- 關於Eclipse的提示 The serializable class XXXXXX does not declare a static final serialVersionUID field of type long
- 启动 Eclipse提示“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- 关于使用MyEclipse启动web项目时工具报 The specified JRE installation does not exist 错误提示解决方法
- Eclipse 出现Some sites could not be found. See the error log for more detail.错误 解决方法
- Eclipse: alt+/快捷键智能提示弹出错误的解决方法
- eclipse创建maven项目时,添加src/main/java会提示 The folder is already a source folder.解决方法
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- 【转】启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法! .
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法
- 启动 Eclipse 弹出 Failed to load the JNI shared library jvm.dll 错误的解决方法
- Eclipse启动时错误提示及解决方法
- NDK的错误ERROR: The device does not support the application's targetted CPU ABIs!解决方法
- Eclipse运行时提示failed to create the java virtual machine 解决方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误的解决方法!
- Eclipse 弹出 Failed to load the JNI shared library jvm.dll 错误的解决方法!
- Eclipse:Could not create the view: Plug-in org.eclipse.jdt.ui was unable to load class org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart. 解决方法
- 启动Eclipse 弹出“Failed to load the JNI shared library”错误的解决方法