How to generate serialVersionUID in Intellij IDEA

In IntelliJ IDEA, we need to enable this auto-generate serialVersionUID option manually.

P.S Tested with IntelliJ IDEA 2019.3.4, it should work the same in other versions.

Intellij IDEA Settings

File -> Settings -> Editor -> Inspections -> Java -> Serialization issues:

Find serialization class without serialVersionUID and check it.

Inspections

Back to the editor, clicks on the class name, ALT + ENTER (Windows), it will prompts the Add serialVersionUID field option.

Serialization issues

A new serialVersionUID is auto-generated.


public class Address implements Serializable {

    private static final long serialVersionUID = -2338626292552177485L;

}

Done.

References

author image

mkyong

Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities. Read all published posts by

Comments

avatar