首页 > 编程语言 > 详细

【spring-boot】spring-boot使用JPAJ进行数据访问时,提示:org.hibernate.InstantiationException: No default constructor for entity: : com.springboot.jpa.entity.User

时间:2019-08-05 20:14:31      阅读:114      评论:0      收藏:0      [点我收藏+]

错误:org.hibernate.InstantiationException: No default constructor for entity:  : com.springboot.jpa.entity.User

解决方案:

  在相应的实体类中,创建一个无参数的构造方法即可。

@Entity
@Table(name = "tb_users")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)// 自增主键
    private Integer id;

    @Column(name = "name")
    private String name;
    @Column(name = "age")
    private Integer age;
    @Column(name = "sex")
    private String gender;
  
  //解决方案:
public User() { }

 

【spring-boot】spring-boot使用JPAJ进行数据访问时,提示:org.hibernate.InstantiationException: No default constructor for entity: : com.springboot.jpa.entity.User

原文:https://www.cnblogs.com/jums/p/11304827.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!