flyway报错Correct the classpath of your application so that it con

举报
刘大猫 发表于 2025/09/15 21:42:09 2025/09/15
【摘要】 flyway报错Correct the classpath of your application so that it contains compatible versions of the

image.png

详情错误日志

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.3)

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)
2022-11-01 10:52:01.619  INFO 26424 --- [           main] com.flyway.FlaywayApplication            : No active profile set, falling back to default profiles: default
2022-11-01 10:52:02.677  INFO 26424 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8015 (http)
2022-11-01 10:52:02.691  INFO 26424 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-11-01 10:52:02.691  INFO 26424 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-11-01 10:52:02.778  INFO 26424 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-11-01 10:52:02.779  INFO 26424 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1070 ms
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;
2022-11-01 10:52:03.151  INFO 26424 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-11-01 10:52:03.161  INFO 26424 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-11-01 10:52:03.177 ERROR 26424 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.configureIgnoredMigrations(FlywayAutoConfiguration.java:273)

The following method did not exist:

    org.flywaydb.core.api.configuration.FluentConfiguration.ignoreMissingMigrations(Z)Lorg/flywaydb/core/api/configuration/FluentConfiguration;

The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location:

    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

The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations:

    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

The called method's class hierarchy was loaded from the following locations:

    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


Action:

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

<!--使用flyway-->
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>${flayway.test.version}</version>
</dependency>  

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

<properties>
	<flayway.test.version>6.5.7</flayway.test.version>	
</properties>

详情请看我的博客:↓

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

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。