Reputation: 2813
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
Upvotes: 13
Views: 10397
Reputation: 663
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();
}
}
Upvotes: 9
Reputation: 8960
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
Upvotes: 12