In this post, we will see how to generate SerialVersionUID in Intellij.
There are multiple ways to do it. Let’s go through them.
Table of Contents
Using find action
You can generate SerialVersionUID in intellij by pressing ctrl + shift +A
(find action) and then typing Serializable class without serialVersionUID
and toggle it from Off to On.
Now create a class SerializableExample
and it will implement Serializable
interface and generate serialVersionUID as below:
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; import java.io.Serializable; public class SerializableExample implements Serializable { private static final long serialVersionUID = 7438255714694047836L; } |
Using Settings window
Navigate through following path:
File
-> Settings
-> Editor
-> Inspections
-> Java
-> Serialization issues
and find Serializable class without serialVersionUID
and check it.
Now create a class SerializableExample
and it will implement Serializable interface and generate serialVersionUID as below:
1 2 3 4 5 6 7 8 9 10 |
package org.arpit.java2blog; import java.io.Serializable; public class SerializableExample implements Serializable { private static final long serialVersionUID = 7438255714694047836L; } |
Using Randomly Change serialVersionUID Initializer
You can also press Alt + Enter
on following statement:
1 2 3 |
private static final long serialVersionUID = ; |
Put the cursor after = and press Alt + Enter
to generate serialVersionUID in Intellij.
Using GenerateSerialVersionUID plugin
You can install GenerateSerialVersionUID plugin from the link.
Once you install this plugin, you can Right click
-> Generate
-> SerialVersionUID
to generate SerialVersionUID in Intellij.
That’s all about how to generate SerialVersionUID in intellij.