Reputation: 6140
We are currently upgrading our Spring Boot based application to version 3 but the following issue occurs:
Is there any way to use Spring Boot 3 + Flyway Community + Postgres that is not supported by Flyway Community (in our case 9.5)?
Upvotes: 0
Views: 4533
Reputation: 3899
Spring Boot 3 will only auto-configure Flyway if it is at least version 8 or higher. You can use Spring Boot 3 with older Flyway versions if you disable the auto-configuration and do the configuration yourself.
There are multiple ways to disable the auto-configuration of Flyway:
FlywayAutoConfiguration.class
to the field exclude
of the annotation @SpringBootApplication
(or @EnableAutoConfiguration
),spring.flyway.enabled
to false
, orFlyway
such that the auto-configuration backs off.If the auto-configuration of Spring Boot 2 worked fine for you, then I'd recommend the last approach. You can take the code of FlywayAutoConfiguration
from Spring Boot 2, remove the stuff that's specific for auto-configuration classes (e.g. every annotation whose name starts with Conditional
), and put it in your own code as a normal configuration class annotated with @Configuration
. This class will then expose at least a bean of type Flyway
to let the auto-configuration back off and a bean of type FlywayMigrationInitializer
that performs the actual migrations.
Upvotes: 3