IntelliJ Idea generating serialVersionUID

My question is how to generate this value in IDEA? I go to Settings -> Errors -> Serialization issues -> Serializable class without 'serialVersionUID' but it still dont show me the warning. My class PKladrBuilding parent implements interface Serializable.

Part of the code:

public class PKladrBuilding extends PRQObject

public abstract class PRQObject extends PObject

public abstract class PObject implements Serializable

I am not sure if you have an old version of IntelliJ but If I go File => Settings... => Inspections => Serialization issues => Serializable class without 'serialVersionUID' enabled, the class you provide give me warnings.

在这里输入图像描述

If I try the first class I see

在这里输入图像描述

BTW It didn't show me a warning until I added { } to the end of each class to fix the compile error.


Install GenerateSerialVersionUID plugin by Olivier Descout

Go to: File > Settings > Plugins > Browse repositories > GenerateSerialVersionUID

Install the plugin and restart.

Now you can generate the id from Code > Generate > serialVersionUID or the shortcut.


Without any plugins: You just need to enable highlight in IntelliJ:

IntelliJ Preferences -> Editor -> Inspections -> Java -> Serialization issues -> Serializable class without 'serialVersionUID' - set flag and click 'OK' .

Now, if your class implements Serializable , you will see highlight, and alt+Enter on class name will propose to generate private static final long serialVersionUID .

链接地址: http://www.djcxy.com/p/23860.html

上一篇: 如何通过ssh运行Java框架

下一篇: 生成serialVersionUID的IntelliJ Idea