首页 > 解决方案 > Spring Boot问题中的Flyway集成(企业版)

问题描述

您好,当我在 springboot 项目中使用 flyway Enterprise 时出现此错误:

16:27:46 WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springAsyncConfig': Unsatisfied dependency expressed through field 'customAsyncExceptionHandler'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customAsyncExceptionHandler': Unsatisfied dependency expressed through field 'importHistoryRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'importHistoryRepository': Cannot create inner bean '(inner bean)#31db34da' 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)#31db34da': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration': Unexpected exception during bean creation; nested exception is java.lang.TypeNotPresentException: Type org.flywaydb.core.api.callback.FlywayCallback not present

这是我的 pom.xml 文件:

<dependency>
     <groupId>org.flywaydb.enterprise</groupId>
     <artifactId>flyway-core</artifactId>
     <version>6.0.3</version>
</dependency>

标签: spring-bootflyway

解决方案


此问题相关Flyway 6.xx 与 Spring Boot < 2.2.0 不兼容。

所以你有2个选择:

  • 将 Spring Boot 更新为 >= 2.2.0
  • 使用flyway 5.xx

希望这可以帮助


推荐阅读