No identifier specified for entity: main.java.com.sy.entity.User

自己没怎么搭建过框架,更何况还是spring mvc的,最近在带两个实习生,正好教他们怎么搭建一个spring mvc的框架,然而我在映射表的时候,提示报错了。


实体基类:

public class BaseEntity implements Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    
    @Column(updatable=false)
    protected Date creatTime=new Date();
    
    @Column(updatable=false)
    protected String creatUser;
    
    @Column(insertable=false)
    protected Date updateTime=new Date();
    
    @Column(insertable=false)
    protected String updateUser;

    //get,set方法
}

User类:

@Entity
@Table(name="sys_user")
public class User extends BaseEntity {
    
    private String loginName;
    
    private String userName;
    
    private String password;
    
    //get、set方法
    
}

查阅国外的论坛之后得出一个结论,自己好菜啊!解决办法特别简单!!!在实体基类上加一个 @MappedSuperclass

<span style="color:#ff0000;">@MappedSuperclass</span>
public class BaseEntity implements Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    
    @Column(updatable=false)
    protected Date creatTime=new Date();
    
    @Column(updatable=false)
    protected String creatUser;
    
    @Column(insertable=false)
    protected Date updateTime=new Date();
    
    @Column(insertable=false)
    protected String updateUser;

    //get,set方法

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值