spring boot: javax.persistence.PersistenceException: Unable to build Hibernate SessionFactory

报错信息:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory

原因:

造成这个错误的原因有很多,例如

1、@Entity 类有变动,无非正常生成对应的数据库。
解决:使用 spring: jpa: hibernate:ddl-auto: create 删除之前的数据库,重新重建数据库

2、变量的类型不对,例如:使用list的变量,就会出现这个错误

3、使用多个@Id注解的方式不正确。
解决:如何使用联合主键(复合主键)

4、@Column(name)的注解与数据库字段不匹配。
解决:参考这里

参考:
spring-boot(二) 整合jpa
解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用
解决Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibe

猜你喜欢

转载自blog.csdn.net/xx326664162/article/details/79459114