报错:No identifier specified for entity: main.java.com.sy.entity.User的解决办法
2024-09-21 10:10:20
自己也没怎么搭建过框架,更何况还是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
@MappedSuperclass
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方法 }
最新文章
- 使用oh-my-zsh后导致的卡顿问题
- fMRI数据分析处理原理及方法
- 01python算法--算法和数据结构是什么鬼?
- Chrome渲染Transition时页面闪动Bug
- Bus Pass
- JAVA生成EXCEL图表
- HDU 1548 A strange lift(dij+邻接矩阵)
- Java探秘之神秘的字符串String(二)
- NOIP2017划水崩盘记
- curl支持HTTP和https
- django上传图片简单验证以及自动修改图片名称
- 使用sessionStorage进行数据存值
- google protobuf VC下的使用笔记
- python 怎样获取toast?
- HTML5 <;li>; <;ol>; <;ul>; 用法
- Mongo 3.6.1版本Sharding集群配置
- rsyncd
- Java基础——工厂模式
- 20155308 《网络攻防》 Exp2 后门原理与实践
- [BZOJ 1032][JSOI 2007]祖玛 题解(区间DP)