SpringBoot 遇到 No identifier specified for entity
No identifier specified for entity 从字面上不难看出来是没有设置主键
因为没有为标注为@Entity的实体类注明主键
import lombok.Data;
import org.springframework.data.annotation.Id; import javax.persistence.*; @Data
@Table(name = "user")
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column
private String username;
@Column
private String name;
@Column
private Integer age;
}
但实际上bean用@Id和@GenerateValue标注在ID上,仔细观察发现是导错包:import org.springframework.data.annotation.Id;这是Spring提供的;而应该导入javax.persistence.Id,很细微的差别,可能不注意看就错了而且很难去排查问题
区别在于:org.springframework.data.annotation.Id是spring用来支持MongoDB等非关系型数据库的持久化(spring-data-mongodb等);javax.persistence.Id适用于关系型的数据
SpringBoot 遇到 No identifier specified for entity的更多相关文章
- springboot No Identifier specified for entity的解决办法
今天在做一个项目的时候遇到一个问题,实体类忘了指定主键id,然后报如下错误,也是自己粗心大意造成的,在此记录下. java.lang.IllegalStateException: Failed to ...
- No identifier specified for entity: springboot-jpa报错No identifier specified for entity
说明:此次学习使用了springboot框架,jpa注解映射实体类 1,No identifier specified for entity: com.tf.model.User 看到此错误第一反应百 ...
- Mingyang.net:No identifier specified for entity
org.hibernate.AnnotationException: No identifier specified for entity: net.mingyang.modules.system.C ...
- No identifier specified for entity
主键问题 使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for ent ...
- SpringBoot2 JPA No Identifier specified for entity的解决办法
No Identifier specified for entity的错误 此类注解都在 import javax.persistence.*;包下 @Id @GeneratedVal ...
- JPA error org.hibernate.AnnotationException: No identifier specified for entity
错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...
- 报错HTTP Status 500 - The given object has a null identifier: cn.itcast.entity.Customer; nested exception is org.hibernate.TransientObjectException: The given object has a null identifier:
在使用模型驱动封装的时候,要保证表单中name属性名和类中属性名一致,否则将会报错如下: HTTP Status 500 - The given object has a null identifie ...
- Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...
随机推荐
- python常用数据结构讲解
一:序列 在数学上,序列是被排成一排的对象,而在python中,序列是最基本的数据结构.它的主要特征为拥有索引,每个索引的元素是可迭代对象.都可以进行索引,切片,加,乘,检查成员等操作.在py ...
- Ubuntu+docker+jenkins安装详细指南
最近项目上开始实行自动化测试,避免不了与jenkins等持续集成工具打交道,今天就给大家分享一下有关jenkins的简单安装和使用 1,准备环境 (1)ubuntu系统 (2)docker (3)je ...
- 使用Espresso测试记录
准备工作 建立测试项目 添加测试依赖 编写Espresso测试 运行测试并检查测试结果 建立测试项目 使用Android Studio建立测试项目,Activity模版使用 LoginActivity ...
- layui select获取自定义属性值
layui-select写法: <option value='> 我想在点击的时候获取自定义属性data-method的值,其中selectId是该select的id form.on('s ...
- myql忽略大小写问题解决
linux系统下启动mysql默认是区分大小写的,如果刚好项目中使用的表名与数据库中表名大小写有冲突,此时就需要忽略mysql表名大小写了. 解决方式一: 1.关闭数据库 mysqladmin -ur ...
- hadoop之yarn详解(基础架构篇)
本文主要从yarn的基础架构和yarn的作业执行流程进行阐述 一.yarn的概述 Apache Yarn(Yet Another Resource Negotiator的缩写)是hadoop集群资源管 ...
- scalikejdbc 学习笔记(2)
使用scalikejdbc config (src\main\resources) # MySQL(dev) dev.db.default.driver="com.mysql.jdbc.Dr ...
- slf4j输出变量
花括号表示占位符,推荐使用
- github代码仓库提示:“We found a potential security vulnerability in one of your dependencies”
问题描述: Github上传代码后出现这样的错误: We found a potential security vulnerability in one of your dependencies. A ...
- java集合类之LinkedList详解
一.LinkedList简介 由于LinkedList是一个实现了Deque的双端队列,所以LinkedList既可以当做Queue,又可以当做Stack,在将LinkedList当做Stack时,使 ...