Shubham Shekhar
Shubham Shekhar

Reputation: 137

Flyway version declared in Pom causing conflict

I am upgrading my java to version 17(spring boot version-3.0.4), but I need to use flyway-core dependency as 6.5.7 only as it is the last flyway version available that supports mysql 5.7(which I need to use in my project). But when I run my junits I get below error:- 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.FlywayAutoConfiguration$FlywayConfiguration.configureProperties(FlywayAutoConfiguration.java:187)

The following method did not exist:

'org.flywaydb.core.api.configuration.FluentConfiguration org.flywaydb.core.api.configuration.FluentConfiguration.failOnMissingLocations(boolean)'

The calling method's class, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration, was loaded from the following location:

jar:file:/C:/Users/sx8428/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.0.4/spring-boot-autoconfigure-3.0.4.jar!/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class

The called method's class, org.flywaydb.core.api.configuration.FluentConfiguration, is available from the following locations:

jar:file:/C:/Users/sx8428/.m2/repository/org/flywaydb/flyway-core/7.5.4/flyway-core-7.5.4.jar!/org/flywaydb/core/api/configuration/FluentConfiguration.class

The called method's class hierarchy was loaded from the following locations:

org.flywaydb.core.api.configuration.FluentConfiguration: file:/C:/Users/sx8428/.m2/repository/org/flywaydb/flyway-core/7.5.4/flyway-core-7.5.4.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration and org.flywaydb.core.api.configuration.FluentConfiguration

I need to find a way to exclude spring from automatically configuring flyway version.

Upvotes: 0

Views: 3090

Answers (2)

Boris
Boris

Reputation: 1136

Here's a solution for you problem

  1. The latest version of Community Flyway that supports MySQL 5.7 is indeed 7.15.0

  2. The latest version of Spring that supports version of Flyway up to 7.15.0 is 2.5.x

Therefore, what you can do is to use version of Flyway 7.7.3 and copy flyway folder from that version of Spring to your source code.
Everything else from Spring will be from original version and only Flyway will be replaced.

Upvotes: 0

scrhartley
scrhartley

Reputation: 1512

To disable Spring using FlywayAutoConfiguration, set spring.flyway.enabled=false (see here).

If you want to find an older version of FlywayAutoConfiguration that behaves as you want, then try looking through the old versions here and copy it into you project.
You will need to remove this from your copy:

@ConditionalOnProperty(prefix = "spring.flyway", name = "enabled", matchIfMissing = true)

Upvotes: 0

Related Questions