查看网上的资料,应该是报错的实体类com.example.domain.p.User中没有添加加主键的注解@Id,这个是必须的。但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢?

后来检查了很久,发现是我import的包出现了错误,正确的应该是import javax.persistence.Id 而我却导入了org.springframework.data.annotation.Id 这样虽然@Id 在IDE语法检查时不会报错,但并不是我们本来想要的那个功能,因此运行时会报上面但错误。

以后还是要细心一些啊!
---------------------
作者:LouisLee变强大
来源:CSDN
原文:https://blog.csdn.net/qq_24082175/article/details/79084677
版权声明:本文为博主原创文章,转载请附上博文链接!

Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误的更多相关文章

  1. 解决Entity 实体类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误

    启动报错如下图所示: 解决方案: 查看网上的资料,大部分都说在实体类中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查了很久,发现是我 ...

  2. org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误

    最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...

  3. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  4. org.hibernate.AnnotationException: No identifier specified for entity:

    使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...

  5. JPA error org.hibernate.AnnotationException: No identifier specified for entity

    错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...

  6. Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...

  7. org.hibernate.AnnotationException: No identifier specified for entity 错误解决

    主键对应的属性上加上@Id注解,对应javax.persistence.Id @Id private Long id;

  8. org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter

    因为我的hibernate映射表没有主键所以报这个错. 解决方案是: 1.创建一个主键 2.hibernate处理无主键的表的映射问题,其实很简单,就是把一条记录看成一个主键,即组合主键<com ...

  9. Java初学者作业——定义一个计算器类, 实现计算器类中加、 减、 乘、 除的运算方法, 每个方法能够接收2个参数。

    返回本章节 返回作业目录 需求说明: 定义一个计算器类, 实现计算器类中加. 减. 乘. 除的运算方法, 每个方法能够接收2个参数. 实现思路: 定义计算器类. 定义计算器类中加.减.乘.除的方法. ...

随机推荐

  1. AQS2--出队

    队列不卡死,一定要:前面节点变成头结点唤醒时候能够唤醒后面节点,依次类推. 设置前面节点=-1就是为了前面节点走的时候,唤醒自己. 正常没有阻塞节点,设置前面=-1,再旋转一次尝试获取锁,才阻塞.即使 ...

  2. linux shell 写swoole重启脚本

    linux shell 写swoole重启脚本 代码如下<pre>#!/bin/shkill `lsof -t -i:9501`sleep 2php /data/web/mircoweb/ ...

  3. 给电脑提升权限---- 切换为administrator

    在装系统的时候我们都会在安装的时候进行创建用户这一操作,安装软件的时候总会出现权限不足的情况, 个人建议:如果你要是比较会使用电脑的话,可以体验一下超级管理员这一角色, 就是安装好了之后,切换为超级管 ...

  4. IAR_STM32_CCM内存使用

    在IAR中,硬件环境为STM32F464单片机,额外的CCM不能用DMA访问,但可以作为内部额外扩充RAM使用 修改文件中的内容为: define symbol __ICFEDIT_region_RO ...

  5. ImportBeanDefinitionRegistrar接口实现bean动态注入

    借助ImportBeanDefinitionRegistrar接口实现bean的动态注入https://www.jianshu.com/p/2b993ced6a4c ImportBeanDefinit ...

  6. VS2019 Nuget找不到包的问题处理

    VS不记得改了什么设置之后,发现找不到EF 解决办法 1.点击右侧的设置按钮 2.弹出窗中左侧树形结构选择“程序包源”,再点击右上方的添加按钮 输入一下信息:https://www.nuget.org ...

  7. 在RedHead中安装Oracle

    配置Linux系统下Oracle的安装环境. 1.检查和更新所需软件包. # rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils- ...

  8. T-SQL 批量更新字段

    ;WITH IdPhone AS ( SELECT * FROM(VALUES ('), ('), ('), ('), ('), ('), ('), ('), ('), (') ) AS v(Id, ...

  9. 如何在JIRA中有效使用关注和@提及 我正在关注的问题 提及我的问题 在仪表板上显示

    如何在JIRA中有效使用关注和@提及http://bbs.51testing.com/forum.php?mod=viewthread&tid=1157043&fromuid=1530 ...

  10. Java IO---序列化和反序列化

    一.序列化和反序列化介绍 什么是序列化和反序列化? ​ 序列化就是将对象转换为字节序列的过程. ​ 反序列化就是将字节序列恢复为对象的过程. 序列化的用途在哪? 通常情况下,序列化有两个用途: 将对象 ...