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:

[! [java-serialVersionUID-06](https://cdn.ossez.com/discourse-uploads/optimized/1X/26cc0c7c9c8096a5414acdafbf8e2a07f3f9dab9 _2_690x345.png)](https://cdn.ossez.com/discourse-uploads/original/1X/26cc0c7c9c8096a5414acdafbf8e2a07f3f9dab9.png “java-serialVersionUID-06”)
[https://www.ossez.com/t/intellij-idea-serialversionuid/486](https://www.ossez.com/t/intellij-idea-serialversionuid/486)