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

时间:2014-04-13 19:15:44

标签: java java-ee serialization model playframework

我正在编写一个Play框架实体,它从play.db.ebean.Model延伸并从eclipse获得此警告:

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

任何人都可以向我解释这个吗? play.db.ebean.Model(http://www.playframework.com/documentation/2.0.3/api/java/play/db/ebean/Model.html)没有实现serializable,我的User类也没有,我不明白为什么eclipse会抛出警告。

以下是我的代码的重要部分:

package models;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.persistence.Entity;
import javax.persistence.Id;

import crypto.PasswordHash;
import play.Logger;
import play.db.ebean.Model;
import play.data.validation.*;

@Entity
public class User extends Model {

    @Id
    @Constraints.Email
    private String email;
    @Constraints.Required
    private String name;
    @Constraints.Required
    @Constraints.MinLength(5)
    private String password;
    @Constraints.Min(0)
    private Integer rating;

    ...

}

1 个答案:

答案 0 :(得分:1)

虽然在您链接的javadoc中没有这样说,play.db.ebean.Model实现com.avaje.ebean.bean.EntityBean(请参阅https://github.com/playframework/play-ebean/blob/master/play-ebean/src/main/java/play/db/ebean/Model.java),而java.io.Serializable又延伸{{1}}(参见{{3} }})。所以,Eclipse是正确的。