为了账号安全,请及时绑定邮箱和手机立即绑定

Spring 教程:创建名为“entityManagerFactory”

Spring 教程:创建名为“entityManagerFactory”

扬帆大鱼 2021-12-10 16:27:42
我尝试按照有关 springboot 和使用 JPA 访问数据的官方 spring.io教程进行操作。这是关于用 h2 数据库做一些“简单”的操作。关于这个主题还有一些其他问题,但他们的解决方案都不适合我。如果这很重要,我正在使用 java 11 sdk。我什至从教程中下载了 .zip 文件,但无论我做什么,我总是得到以下错误消息: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    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]这是我的 build.gradle 文件的依赖块dependencies {    // https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api    compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.6.RELEASE'    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.6.RELEASE'// https://mvnrepository.com/artifact/com.h2database/h2    compile group: 'com.h2database', name: 'h2', version: '1.4.197'}
查看完整描述

1 回答

?
四季花海

TA贡献1811条经验 获得超5个赞

添加此依赖项:

 compile group: 'org.javassist', name: 'javassist', version: '3.23.1-GA'

javassist 在 Java 11 中存在问题。


查看完整回答
反对 回复 2021-12-10
  • 1 回答
  • 0 关注
  • 266 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号