解决Entity 实体类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
启动报错如下图所示:

解决方案:
查看网上的资料,大部分都说在实体类中没有添加加主键的注解@Id,这个是必须的。但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢?
后来检查了很久,发现是我import的包出现了错误,正确的应该是import javax.persistence.Id 而我却导入了org.springframework.data.annotation.Id 这样虽然@Id 在IDE语法检查时不会报错,但并会使我编译错误起不来,因此运行时会报上面但错误。
参考文章:https://blog.csdn.net/qq_24082175/article/details/79084677
解决Entity 实体类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误的更多相关文章
- Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
查看网上的资料,应该是报错的实体类com.example.domain.p.User中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查 ...
- 解决SpringDataJpa实体类中属性顺序与数据库中生成字段顺序不一致的问题
一.在application.yml配置中添加数据库根据实体类自动创建数据库表的配置(这里数据库采用MySQL数据库) jpa: database: MYSQL show-sql: true #Hib ...
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...
- org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误
最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...
- org.hibernate.AnnotationException: No identifier specified for entity:
使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...
- JPA error org.hibernate.AnnotationException: No identifier specified for entity
错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...
- Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...
- Hibernate jpa 在实体类中对于时间的注解
在时间类型DATE 属性上添加一个 @Temporal(TemporalType.DATE)(精确到年月日)@Temporal(TemporalType.TIME)(精确到时分秒)@Temporal( ...
- 关于entityframework 自动生成实体类中加验证的属性重新生成后属性被覆盖解决办法
1.手动创建一个部分类 (你可以手动创建 partial class, 内容为空) [MetadataType(typeof(AppleMetadata))] public partial class ...
随机推荐
- SpringBoot 使用IDEA 配置热部署
在开发中稍微更改一点内容就要重启,很麻烦.这个时候使用Spring Boot的热部署就能解决你的问题. 上图: 1,在pom.xml文件中添加依赖: <dependency> <gr ...
- 在Spring Boot中添加全局异常捕捉提示
在一个项目中的异常我们我们都会统一进行处理的,那么如何进行统一进行处理呢? 全局异常捕捉: 新建一个类GlobalDefaultExceptionHandler, 在class注解上@Controll ...
- VLAN实验2(配置Trunk接口)
本实验基于<HCNA网络技术实验指南> 本实验使用eNSP软件 原理概述: 在以太网中,通过划分VLAN来隔离广播域和增强网络通信的安全性.以太网通常由 多台交换机组成,为了使VLAN的数 ...
- JQuery动态添加控件并取值
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 转战C#_001
---------------尽量用最少的语言描述 C# 世界里的所有事物------------------- 1. C#(pronounced "C-sharp") is an ...
- ecosystem.config
ecosystem.config.js module.exports = { apps : [{ name : 'TOB_NODE', script : 'app.js', // 开发环境变量 env ...
- Java修炼——面向对象_抽象类和抽象方法
抽象类和抽象方法 什么是抽象类? 使用 abstract 修饰的类称为抽象类 public abstract class Person { } 抽象类的特征 1) 抽象类不可以创建对象 2) 抽象类可 ...
- 第3节:Java基础 - 必知必会(上)
第3节:Java基础 - 必知必会(上) 本篇是基础篇的第一小节,我们从最基础的java知识点开始学习.本节涉及的知识点包括面向对象的三大特征:封装,继承和多态,并且对常见且容易混淆的重要概念覆盖和重 ...
- Yii2框架那些折磨人的坑
说点闲话 距离上次写博客,已经有一年了.在动手写之前,总是带着深深的罪恶感.被它折磨许久,终于,还是,动手了. 值得庆祝的一件事:最近开始健身了.每天动感单车45分钟,游泳45分钟,真的是(生)爽(不 ...
- 垂直方向margin重叠原因与解决方法
参考博客:https://blog.csdn.net/weixin_33743661/article/details/88755435