查看网上的资料,应该是报错的实体类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. Rancher 构建 CI/CD 自动化流程 - 动态配置 Jenkins-slave(二)

    一.说明 1.1 说明 前面介绍采用 Jenkinsfile + KubernetesPod.yaml 方式进行部署项目(Rancher 构建 CI/CD 自动化流程 - 动态配置 Jenkins-s ...

  2. [原创]开源跨平台大型网络端口扫描器K8PortScan(支持批量A段/B段/C段/IP列表)

    0x000 K8PortScan Python版Cscan端口扫描器 Code: https://github.com/k8gege/K8PortScan K8portScan 1.0 Date: 2 ...

  3. CentOS7安装Node_exporter(二进制)

    一.概述 Node_exporter是可以在* Nix和Linux系统上运行的计算机度量标准的导出器.Node_exporter 主要用于暴露 metrics 给 Prometheus,其中 metr ...

  4. 『2019 SummerCamp 总结』

    做题 对于习题方面,我们感觉一个暑假还是留下了不少的题要写,大部分应该是讲师讲课的例题,还有少部分考试题.考试题没有订正完是因为还有算法不会,或是因为题太毒瘤了不会.同时,也发现自己还是有很多应该学的 ...

  5. golang学习笔记--包导入及go 常用命令及参数

    包导入:包导入路劲即代码包在工作区的src目录下的相对路径. 同一个源码文件中导入的多个代码包的最后一个元素不能重复,否则引起编译错误,如果只导入不使用,同样会引起编译错误 若想导入最后一个元素名相同 ...

  6. ASP.NET SignalR 系列(八)之跨域推送

    前面几章讲的都是同域下的推送和订阅.这种讲讲如何跨域 对于SignalR来说,默认是不允许跨域的,因为安全问题.虽如此,但同时提供了跨域方案. 两种跨域方式: 1:JSONP2:CORS JSONP的 ...

  7. Ubuntu 18.04 RTX2080(ti) + tensorflow-gpu + cuda9.0 + gcc5 兼容性问题解决

    0.下载display driver.cuda和cudnn RTX2080 Display Driver cuda cudnn 1. 禁止系统默认的显卡驱动 打开系统黑名单 sudo gedit /e ...

  8. vue--设置cookie

    Vue-CLI项目-vue-cookie与vue-cookies处理cookie vue-cookie 一.模块的安装 npm install vue-cookie --save #--save可以不 ...

  9. android中fragment卡顿的原因

    首页的ViewPager有十几个Fragment,在快速切换的时候,容易产生卡顿现象. 二.分析当ViewPager切换到当前的Fragment时,Fragment会加载布局并显示内容,如果用户这时快 ...

  10. Java String 字符串

    equals 字符串比较 String str = "furong"; String str1 = new String("furong"); System.o ...