实现步骤:
1.安装GenerateSerialVersionUID插件
2.点击idea左上角File -> Settings -> Editor -> Inspections -> 搜索 Serialization issues ,找到 Serializable class without ‘serialVersionUID’ ->打上勾,再点击Apply->OK
3.重启idea
4.新建Class类,实现Serializable,选中对应的类名,按 alt+enter
出现添加serialVersionUID选项,选中则会自动生成serialVersionUID:
package com.example.demo.entity;
import java.io.Serializable;
/**
* @author qzz
* @date 2023/3/21
*/
public class User implements Serializable {private static final long serialVersionUID = 7598337456152102560L;
/**
* 用户姓名
*/
private String name;/**
* 手机号
*/
private String phone;
}