IDEA—Settings for automatically generating serialVersionUID

        When using Java native serialization, serialVersionUID is the serialization version ID, which ensures that the serialized class and the deserialized class are the same class. If the serialVersionUID is not the same during deserialization, an InvalidClassException will be thrown.

General tutorials online

Click File -> Settings -> Editor -> Inspections -> Search for Serialization issues in the upper left corner of the idea, find Serializable class without 'serialVersionUID' -> check the box, and then click Apply-> OK

        I read many settings on the Internet to automatically generate serialVersionUID, but I found that in my version, there is no serialzable class without "serialVersionUID" in Serialization issues. It just changed the place. Search serialVersionUID directly in Inspections and you can see

Place it in the JVM languages ​​directory and check it

You also need to check the blue one in the picture below

 Then click Apply - OK

Finally, after setting, select the corresponding class name and press alt+enter (MAC: option+enter) shortcut key as shown in the figure below:

 

Guess you like

Origin blog.csdn.net/weixin_42823298/article/details/128621677