报错Could not get constructor for org.hibernate.persister.entity...
来源:11-5 -Spring Security 实战-前台编码
Pinkcoix
2019-01-22
详细报错信息如下:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
上网查阅相关资料都说是实体类没有实现映射,可能是缺少setter getter或是不规范之类,但是我的代码完全按照老师来的,下面是User实体类的代码:
package com.sherry.springboot.blog.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity // 实体
public class User {
@Id // 主键
@GeneratedValue(strategy=GenerationType.IDENTITY) // 自增策略
private Long id; // 实体一个唯一标识
private String name;
private String email;
protected User() { // 无参构造函数;设为 protected 防止直接使用
}
public User(Long id, String name, String email) {
this.id = id;
this.name = name;
this.email = email;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return String.format("User[id=%d,name='%s',email='%s']", id, name, email);
}
}
请问问题是出在哪里呢?
1回答
-
Hibernate 的配置有问题吧~
022019-01-23
基于Spring Boot技术栈博客系统企业级前后端实战
1296 学习 · 738 问题
相似问题