In eclipse, it is often prompted that:
The serializable class adduserform does not declare a static final serialversionuid field of type long
Check it, as shown below:
Serialversionuid is used to indicate the compatibility between different versions of the class. If you modify this class, you need to modify this value. Otherwise, errors will occur when the class serialized in the old version is restored.
You can use the serialver.exe tool in the bincatalog of JDK to generate the serialversionuid.
For test. Class, run the command: serialver Test
To ensure the compatibility of the class version during deserialization, it is best to add the Private Static final long serialversionuid attribute to each class to be serialized. The specific values are defined by yourself. In this way, even if a class is modified after the corresponding object has been serialized, the object can still be correctly deserialized. Otherwise, if this attribute is not displayed, the JVM calculates the attribute value based on the class information. The calculation result of the modified class is often different from that of the modified class, this causes object deserialization to fail because the class version is incompatible.
Another disadvantage of not displaying the definition of this property value is that it is not conducive to program porting between different JVMs. Because different compilers may implement different calculation policies for this attribute value, although the class is not changed, the JVM is different, there is still a problem that the class version is incompatible and cannot be correctly deserialized.
You can use Ctrl + 1 for automatic correction :-)