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

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

9 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Dirk Ulrich
4 years ago

In IntelliJ IDEA 2021.3 (Ultimate Edition) it’s moved to IntelliJ IDEA -> Preferences -> Editor -> Inspections -> JVM languages
Maybe better approach:
Double pressing [Shift]. In the appearing dialog chose the Actions menu and type ‘Serializable class without’ and select the item to toggle it on/off.

victor
3 years ago
Reply to  Dirk Ulrich

thx

Ranjan Singh
5 years ago

Thank you. Quite helpful, since in my terminal for serialver, it was showing – command not found : serialver

klaillton
5 years ago

Thank you, I’m starting with Intellij and this is very tricky

Dirk Ulrich
4 years ago

In IntelliJ IDEA 2021.3 (Ultimate Edition) it’s moved to IntelliJ IDEA -> Preferences -> Editor -> Inspections -> JVM languages

Kbirhan
4 years ago

it has been moved to File -> Settings -> Editor -> Inspections -> Jbm -> Serialization issues:

Kbirhan
4 years ago
Reply to  Kbirhan

* File -> Settings -> Editor -> Inspections -> Jvm -> Serialization issues:

Fogo
4 years ago

Nice

Ian
5 years ago

Thank you!