gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 13:08:54 25 4
gpt4 key购买 nike

我正在编写一个从 play.db.ebean.Model 扩展的 Play Framework 实体,并从 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 ) 没有实现可序列化,我的 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;

...

}

最佳答案

虽然在您链接的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.Serialized (请参阅 http://www.avaje.org/static/javadoc/pub/com/avaje/ebean/bean/EntityBean.html )。所以,Eclipse 是正确的。

关于java - 可序列化类 X 未声明 long 类型的静态最终 serialVersionUID 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23047246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com