首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将Flyway 4.1.2升级到6.4.4会导致NoSuchMethodError: org.flywaydb.core.Flyway.getLocations()

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

Stack Overflow用户
提问于 2020-07-21 01:08:32
回答 1查看 782关注 0票数 1

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

代码语言:javascript
复制
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配置:

代码语言:javascript
复制
@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的片段:

代码语言:javascript
复制
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'
  ...
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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

代码语言:javascript
复制
testCompile group: 'org.flywaydb.flyway-test-extensions', name: 'flyway-spring-test', version: '5.0.1'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63000510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档