In IntelliJ IDEA we need automatic serialVersionUID creation, how to configure.
Intellij IDEA set
Go to the Settings of Intellij IDEA and go to the following path: File -> Settings -> Editor -> Conforms -> Java -> Serialization Issues
Then find the Serialization Class Without serialVersionUID option and select.
Then go to the text editor
Select ALT + ENTER (Windows), then select the Add serialVersionUID field option.
IntelliJ IDEA will automatically generate uids
private static final long serialVersionUID = 7364069549053183236L;
How to set serialVersionUID without modifying Intellij IDEA
The above method needs to be modified by Intellij IDEA to generate the serialVersionUID. You can also use the following method to generate serialVersionUID without making configuration changes to Intellij IDEA.
Type in the code:
private static final long serialVersionUID = 1L;
Copy the code
You will then see a warning in front of it:
You can then see that the random serialVersionUID is created.
Or you can use the ALT + ENTER shortcut.
The generated result is as follows: