【问题标题】:Spring boot update from 1.4.0 to 1.5.10 entityManagerFactory issueSpring boot 从 1.4.0 更新到 1.5.10 entityManagerFactory 问题
【发布时间】:2018-03-19 10:26:33
【问题描述】:

我已将 springboot 从 1.4.0 更新到 1.5.10,然后使用 jhipster 重新生成实体。当我尝试运行代码时,我得到了这个异常 -

   Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration' defined in file [C:\WorkArea\hotfix-new\target\classes\com\info\config\SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 3; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.zalando.problem.spring.web.advice.security.SecurityProblemSupport': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'auditEventMvcEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.class]: Unsatisfied dependency expressed through method 'auditEventMvcEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customAuditEventRepository' defined in file [C:\WorkArea\hotfix-new\target\classes\com\info\repository\CustomAuditEventRepository.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistenceAuditEventRepository': Cannot create inner bean '(inner bean)#186bf8ab' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#186bf8ab': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

如果有人有想法,请提出建议。

【问题讨论】:

  • 是的。我的想法是阅读错误信息。它清楚地表明缺少某些东西。
  • 在重新生成之前,您是否也更新了 jhipster?因为从 SB 1.4 迁移到 1.5 已经由 jhipster 自己管理。 jhipster.tech/upgrading-an-application
  • 是的,我已经更新了 jhipster,然后是 spring

标签: java spring-boot jhipster


【解决方案1】:

EntityManagerFactory 通常由org.springframework.boot:spring-boot-starter-data-jpa 依赖注册。您更新的项目中有它吗?

【讨论】:

  • 您是否使用@EnableAutoConfiguration 并且spring-boot-starter-data-jpa 没有提供范围?通常这个缺失的 bean 由 JpaBaseConfiguration 注册,这取决于 spring.jpa 属性。
猜你喜欢
  • 2019-04-16
  • 2020-04-29
  • 2018-12-15
  • 2018-09-16
  • 2019-07-16
  • 2018-01-03
  • 2018-08-18
  • 1970-01-01
  • 2019-01-13
相关资源
最近更新 更多