明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
随笔 - 1277, 文章 - 0, 评论 - 214, 阅读 - 320万
  博客园  :: 首页  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
2023-06-10 21:29:04.460  WARN 24060 --- [           main] ConfigServletWebServerApplicationContext : 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/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
2023-06-10 21:29:04.468  INFO 24060 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
2023-06-10 21:29:04.509  INFO 24060 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

 

无法初始化 JPA EntityManagerFactory:无法创建请求的服务 [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

或者

Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/zero/xunwuproject/config/JpaConfig.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

这个错误有多种原因导致,在网上查了一下, 大概有以下几种原因:

  1. 实体类的属性对象没有设置setter或者getter。

    http://stackoverflow.com/questions/18042247/could-not-get-constructor-for-org-hibernate-persister-entity-singletableentitype

  2. 没有导入javassist的jar文件 (javassist-3.15.0-GA.jar什么的)

    http://blog.csdn.net/xiaochangwei789/article/details/7712725

  3. 实体类中的属性对象名和映射文件的property name不一致。

    https://blog.csdn.net/liuzhengyang1/article/details/23127629

而我这里是第二个原因,缺少javassist的jar包,于是在pom文件中引入:

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.23.1-GA</version>
</dependency>

解决办法:缺少  javassist-3.15.0-GA.jar  包,版本未定。引入了这个jar包后,启动就正常了。

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2009-06-10 .net 接收存储过程的返回值 。。。。
点击右上角即可分享
微信分享提示