Upgrading Flyway 4.1.2 to 6.4.4 results in NoSuchMethodError: org.flywaydb.core.Flyway.getLocations()
Upgrading Flyway 4.1.2 to 6.4.4 results in NoSuchMethodError: org.flywaydb.core.Flyway.getLocations()
我一直在将 Spring 应用程序从 1.5.4 升级到 2.3.1。随后,Flyway 从 4.1.2 升级到 6.4.4。我现在面临的问题是,当某些 Flywaytests 运行 时,会抛出以下异常:
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.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access0(ParentRunner.java:66)
at org.junit.runners.ParentRunner.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'
...
}
这可能是 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'
我一直在将 Spring 应用程序从 1.5.4 升级到 2.3.1。随后,Flyway 从 4.1.2 升级到 6.4.4。我现在面临的问题是,当某些 Flywaytests 运行 时,会抛出以下异常:
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.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access0(ParentRunner.java:66)
at org.junit.runners.ParentRunner.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'
...
}
这可能是 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'