Generate serialVersionUID in IntelliJ IDEA

In this short post, I will be sharing how to generate serialVersionUID in Intellij Idea. In IntelliJ Idea, we need to manually enable the auto-generate serialVersionUID option. It is tested with IntelliJ 2021.3.1, it should work the same in other versions too.

Intellij IDEA Settings on Mac and Windows

1. IntelliJ Idea -> Preferences -> Editor -> Inspections -> Java -> JVM languages -> Serializable class without serialVersionUID -> set flag and click 'OK'. (For Windows: settings is under 
File -> Settings -> Editor ...)
intellij serialversionUID checkbox


2. If your class implements Serializable, hover over the class name(for example Employee) and click on the 'Create constant field 'serialVersionUID' in classname'  as shown below in the image.
intellij serialVersionUID class hover

3. Finally, a new serialVersionUID is auto-generated.

intelliJ serialversionUID generated


That's all for today, please mention in the comments in case you have any questions related to how to generate serialVersionUID in IntelliJ IDEA.

About The Author

Subham Mittal has worked in Oracle for 3 years.
Enjoyed this post? Never miss out on future posts by subscribing JavaHungry