IntelliJ IDEA: How to generate ‘serialVersionUID’
When Java class implements Serializable interface you have the following options:
- don’t declare serialVersionUID explicitly
- add default serialVersionUID(1L)
- generate _serialVersionUID_value

It is_strongly recommended_that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpectedInvalidClassException’s during deserialization.
therefore it is wise to choose the latter option.
If you’re using a very popularJava development IDEIntelliJ IDEA, you may find it not straightforward, how to generate the_serialVersionUID_ there. Below is the recipe for the IntelliJ IDEA 12 (latest at the time of writing), hope you’ll find it useful:
- Go to “File” => “Settings… (Ctrl+Alt+S)” => “Inspections” => “Serialization issues”
- … and enable “Serializable classes without ‘serialVersionUID’”

- Then use the IntelliJ IDEA light bulbor press Alt+Enterto generate the field

Image Credits: Labs64


