flyway报错Correct the classpath of your application so that it contains compatible versions of the

心已赠人 2024-04-01 13:36 220阅读 0赞

在这里插入图片描述

详情错误日志

  1. . ____ _ __ _ _
  2. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  3. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  4. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  5. ' |____| .__|_| |_|_| |_\__, | / / / /
  6. =========|_|==============|___/=/_/_/_/
  7. :: Spring Boot :: (v2.6.3)
  8. 2022-11-01 10:52:01.616 INFO 26424 --- [ main] com.flyway.FlaywayApplication : Starting FlaywayApplication using Java 11.0.12 on HYT211145187-01 with PID 26424 (G:\WorkSpace\springboot-test\flyway-test\target\classes started by 211145187 in G:\WorkSpace\springboot-test)
  9. 2022-11-01 10:52:01.619 INFO 26424 --- [ main] com.flyway.FlaywayApplication : No active profile set, falling back to default profiles: default
  10. 2022-11-01 10:52:02.677 INFO 26424 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8015 (http)
  11. 2022-11-01 10:52:02.691 INFO 26424 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  12. 2022-11-01 10:52:02.691 INFO 26424 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
  13. 2022-11-01 10:52:02.778 INFO 26424 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  14. 2022-11-01 10:52:02.779 INFO 26424 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1070 ms
  15. 2022-11-01 10:52:03.148 WARN 26424 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfiguration.ignoreMissingMigrations(Z)Lorg/flywaydb/core/api/configuration/FluentConfiguration;
  16. 2022-11-01 10:52:03.151 INFO 26424 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
  17. 2022-11-01 10:52:03.161 INFO 26424 --- [ main] ConditionEvaluationReportLoggingListener :
  18. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  19. 2022-11-01 10:52:03.177 ERROR 26424 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
  20. ***************************
  21. APPLICATION FAILED TO START
  22. ***************************
  23. Description:
  24. An attempt was made to call a method that does not exist. The attempt was made from the following location:
  25. org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.configureIgnoredMigrations(FlywayAutoConfiguration.java:273)
  26. The following method did not exist:
  27. org.flywaydb.core.api.configuration.FluentConfiguration.ignoreMissingMigrations(Z)Lorg/flywaydb/core/api/configuration/FluentConfiguration;
  28. The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location:
  29. jar:file:/F:/apache-maven-3.6.3/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.3/spring-boot-autoconfigure-2.6.3.jar!/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class
  30. The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations:
  31. jar:file:/F:/apache-maven-3.6.3/repository/org/flywaydb/flyway-core/9.6.0/flyway-core-9.6.0.jar!/org/flywaydb/core/api/configuration/FluentConfiguration.class
  32. The called method's class hierarchy was loaded from the following locations:
  33. org.flywaydb.core.api.configuration.FluentConfiguration: file:/F:/apache-maven-3.6.3/repository/org/flywaydb/flyway-core/9.6.0/flyway-core-9.6.0.jar
  34. Action:
  35. Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration and org.flywaydb.core.api.configuration.FluentConfiguration

错误原因:pom中flyway-core的依赖版本问题,当设置9.6.0时就报这个错误,但当设置6.5.7时就能正常启动,感觉是flyway高版本和springboot2.x版本不匹配的问题导致的问题,具体为啥目前不清楚,只要把flyway版本设置成5.2.1或者6.5.7版本以及之间的版本那都是可以运行的。

第1步:引入pom

  1. <!--使用flyway-->
  2. <dependency>
  3. <groupId>org.flywaydb</groupId>
  4. <artifactId>flyway-core</artifactId>
  5. <version>${
  6. flayway.test.version}</version>
  7. </dependency>

我的项目是父模块模式,所以版本号在父pom中指定

  1. <properties>
  2. <flayway.test.version>6.5.7</flayway.test.version>
  3. </properties>

详情请看我的博客:↓

springboot使用flyway,使用介绍、个人总结及报错场景如何修改

发表评论

表情:
评论列表 (有 0 条评论,220人围观)

还没有评论,来说两句吧...

相关阅读