详情错误日志
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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>
详情请看我的博客:↓