将Flyway 4.1.2升级到6.4.4会导致NoSuchMethodError:org.flywaydb.core.Flyway.getLocations()

时间:2020-07-20 17:08:32

标签: java spring flyway

我一直在将Spring应用程序从1.5.4升级到2.3.1。随后,Flyway从4.1.2升至6.4.4。我现在面临的问题是,当运行某些Flywaytests时,会引发以下异常:

 <FlatList
      data={data}
      legacyImplementation={false}
      renderItem={renderItem}
      keyExtractor={keyExtractor}
      getItemLayout={getItemLayout}
      initialNumToRender={7}
      windowSize={21}
      maxToRenderPerBatch={75}
      updateCellsBatchingPeriod={150}
      removeClippedSubviews
      ListFooterComponent={
        isLoading ? (
          <View style={styles.footer}>
            <Loading type="ios" size={20} color={colors.gray} />
          </View>
        ) : null
      }
 />

这是我的Flyway配置:

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)
    ...

此外,这是我的build.gradle的摘要:

@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);
    }

}

1 个答案:

答案 0 :(得分:1)

这可能与Spring / Spring Boot使用的Flyway版本和flyway-test-extensions不匹配。

在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'