13

I'm trying to upgrade my Spring Boot 2.3.4 app to use Flyway 7.0.0 (the latest version). Previously it was using Flyway 6.5.6. The relevant entries in build.gradle are shown below.

buildscript {
  ext {
    flywayVersion = "7.0.0" // changed from 6.5.6
  }
}

plugins {
  id "org.flywaydb.flyway" version "${flywayVersion}"
}

dependencies {
  implementation "org.flywaydb:flyway-core:${flywayVersion}"
}

flyway {
  url = "jdbc:postgresql://0.0.0.0:5432/postgres"
  user = "postgres"
  password = "secret"
}

The following error occurs when I start the app e.g. with ./gradlew bootRun


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.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:65)

The following method did not exist:

'int org.flywaydb.core.Flyway.migrate()'

The method's class, org.flywaydb.core.Flyway, is available from the following locations:

jar:file:/Users/antonio/.gradle/caches/modules-2/files-2.1/org.flywaydb/flyway-core/7.0.0/623494c303c62080ca1bc5886098ee65d1a5528a/flyway-core-7.0.0.jar!/org/flywaydb/core/Flyway.class

The class hierarchy was loaded from the following locations:

org.flywaydb.core.Flyway: file:/Users/antonio/.gradle/caches/modules-2/files-2.1/org.flywaydb/flyway-core/7.0.0/623494c303c62080ca1bc5886098ee65d1a5528a/flyway-core-7.0.0.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.flywaydb.core.Flyway

6
  • please provide the github code base to check the issue.
    – Anish B.
    Commented Oct 2, 2020 at 14:52
  • @AnishB. github.com/flyway/flyway Commented Oct 2, 2020 at 14:54
  • can you provide your project through github ?
    – Anish B.
    Commented Oct 2, 2020 at 14:56
  • @AnishB. I cannot Commented Oct 2, 2020 at 15:30
  • 7
    In Flyway 7 we made breaking changes to the api, one of which was changing migrate() to return information about what was migrated, instead of just an int. As a result it will not be compatible with spring boot until a new version of springboot is released compiled against this new version. I would advise raising an issue on the spring boot github github.com/spring-projects/spring-boot/issues Commented Oct 2, 2020 at 16:30

3 Answers 3

12

Basically, see Philip's comment on your question.

Flyway 7.x.x is not currently compatible with Spring Boot 2.3.4

Temporary solution is to just downgrade to Flyway 6.5.7 (the last 6.x.x version) until Spring Boot 2.3.5 is released.

Read more and follow the issue here: https://github.com/spring-projects/spring-boot/issues/23514

Support for Flyway's new configuration options: https://github.com/spring-projects/spring-boot/issues/23579

9

In Flyway 7 the signature of migrate changed.

To get Flyway 7.x.x working with Spring Boot 2.3.x you can provide a custom FlywayMigrationStrategy implementation, which calls the the right migrate method.

import org.flywaydb.core.Flyway;
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
import org.springframework.stereotype.Component;

@Component
public class FlywayMigrationStrategyImpl implements FlywayMigrationStrategy {
    @Override
    public void migrate(Flyway flyway) {
        flyway.migrate();
    }
}
1
1

downgrade to Flyway 6.5.7 works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.