[Spring-boot] when the spring-boot using JPAJ data access, prompt: org.hibernate.InstantiationException: No default constructor for entity:: com.springboot.jpa.entity.User

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

solution:

  In the corresponding entity class, create a constructor with no arguments can.

@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() { }

 

Guess you like

Origin www.cnblogs.com/jums/p/11304827.html