如何删除警告可序列化类ClASSNAME不声明long类型的静态最终serialVersionUID字段 [英] how to remove the warning The serializable class ClASSNAME does not declare a static final serialVersionUID field of type long

查看:437
本文介绍了如何删除警告可序列化类ClASSNAME不声明long类型的静态最终serialVersionUID字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个扩展 Exception 类的类,我在Eclipse上收到了这个警告

I create a class which extends Exception class, I got this warning on Eclipse


可序列化类PhoneAlreadyExists不会声明类型为long的静态
最终serialVersionUID字段

The serializable class PhoneAlreadyExists does not declare a static final serialVersionUID field of type long

如何删除它请?

public class PhoneAlreadyExists extends Exception {
    public PhoneAlreadyExists() {
        // TODO Auto-generated constructor stub
        super();
    }

    PhoneAlreadyExists(String message) {
        super(message);
    }

}


推荐答案

在课堂上添加注释 @SuppressWarnings(serial),忽略该警告

Add an annotation @SuppressWarnings("serial") on your class, to ignore that warning

这篇关于如何删除警告可序列化类ClASSNAME不声明long类型的静态最终serialVersionUID字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆