我一直在将Spring应用程序从1.5.4升级到2.3.1。随后,Flyway从4.1.2升级到6.4.4。我现在面临的问题是,当一些Flywaytest运行时,会抛出以下异常:
java.lang.NoSuchMethodError: 'java.lang.String[] org.flywaydb.core.Flyway.getLocations()'
at org.flywaydb.test.junit.FlywayTestExecutionListener.locationsMigrationHandling(FlywayTestExecutionListener.java:313)
at org.flywaydb.test.junit.FlywayTestExecutionListener.dbResetWithAnotation(FlywayTestExecutionListener.java:272)
at org.flywaydb.test.junit.FlywayTestExecutionListener.beforeTestMethod(FlywayTestExecutionListener.java:191)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:289)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
...这是我的Flyway配置:
@Configuration
public class FlywayConfig {
@Bean
public Flyway flyway(final DataSource dataSource) {
return Flyway.configure().dataSource(dataSource).load();
}
@Bean
public FlywayMigrationInitializer flywayInitializer(final Flyway flyway) {
return new FlywayMigrationInitializer(flyway, null);
}
}此外,这是我的build.gradle的片段:
plugins {
id "org.springframework.boot" version "2.3.1.RELEASE"
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
...
}
dependencies {
compile group: 'org.springframework', name: 'spring-aspects'
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-actuator"
compile "org.springframework.boot:spring-boot-starter-thymeleaf"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-configuration-processor"
runtime("org.springframework.boot:spring-boot-properties-migrator")
compile 'org.springframework.data:spring-data-commons'
compile 'org.springframework.data:spring-data-jpa'
compile 'org.springframework.hateoas:spring-hateoas'
compile 'org.springframework.plugin:spring-plugin-core'
compile group: 'org.flywaydb', name: 'flyway-core'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
testCompile group: 'org.flywaydb.flyway-test-extensions', name: 'flyway-spring-test', version: '4.0.1'
...
}发布于 2020-07-21 03:26:13
这可能是Spring / Spring Boot和flyway-test-extensions使用的Flyway版本不匹配。
请参阅GitHub上的以下问题:https://github.com/flyway/flyway-test-extensions/issues/59
请将org.flywaydb.flyway-test-extensions:flyway-spring-test版本升级到(至少) 5.1.0
testCompile group: 'org.flywaydb.flyway-test-extensions', name: 'flyway-spring-test', version: '5.0.1'https://stackoverflow.com/questions/63000510
复制相似问题