zoukankan      html  css  js  c++  java
  • 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方法
    
    }



  • 相关阅读:
    机器学习--决策树
    插入排序、选择排序的实现与性能比较
    【笔记】如何实现属性可修改的函数装饰器
    【笔记】如何为被装饰的函数保存元数据
    【笔记】对文件的一些操作
    【笔记】对字符串的一些操作
    USB鼠标按键驱动
    LCD驱动 15-3
    LCD驱动 15 -2
    LCD驱动 15-1
  • 原文地址:https://www.cnblogs.com/phil_jing/p/15615899.html
Copyright © 2011-2022 走看看