Private static final long serialVersionUID = 1L is used to indicate the compatibility between different versions of the class

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

Explanation of serialVersionUID in Java

function of serialVersionUID:
equivalent to ID card of Java class. Mainly used for version control
serialVersionUID is used to maintain version compatibility during serialization, that is, to keep the uniqueness of the object during version upgrade

in order to maintain version compatibility during serialization, that is to say, during version upgrade, deserialization still keeps the uniqueness of objects one is the default 1L, for example: private static final long serialVersionUID = 1L private static final long serialVersionUID = XXXL

when you implement the serializable interface for a class, if you do not define serialVersionUID, eclipse will provide this
prompt function to tell you to define it. In eclipse, click the warning icon in the class, and eclipse will
automatically give two generation methods. If you don’t want to define it, you can also turn it off in eclipse settings. The settings are as follows:
window = = > Preferences ==> Java ==> Compiler ==> Error/Warnings ==>
potential programming problems
change the warning of serializable class without serialVersionUID to ignore

if you don’t consider the compatibility problem, turn it off, but it’s good to have this function. As long as any class implements the serializable interface, eclipse will give you a warning prompt if you don’t add serialVersionUID. This serialVersionUID is to make the class serializable backward compatible

if your class serialized is saved on the hard disk, but later you change the field of the class (increase or decrease or rename), when you deserialize, an exception will appear, which will cause incompatibility

however, when serialVersionUID is the same, it will de serialize different fields with the default value of type to avoid incompatibility

Similar Posts: