Flyway and Spring Boot integration

Spring-Boot is capable on it’s own to do this.
Just add flyway as dependency to your project and spring-boot will pick it up.
Flyway migration will start when the service starts up.

If you already have some tables in the database add:

spring.flyway.baselineOnMigrate = true 

in your property file to keep flyway calm when it discovers that some tables already exist. 😉

Flyway should pick up your datasource. If you need for example another user or something like that for flyway, you can set these properties:

spring.flyway.url: jdbc:postgresql://${}/${}
spring.flyway.user: MYUSER
spring.flyway.password: MYPWD

(Of course add your values! You can use SPEL to reference other properties)


One word of caution: If you use a clustered database you may encounter problems that multiple instances that are started at the same time try to perform the updates at the same time. This is a problem when the table locks don’t work, which happened to me using a clustered mariaDB.

Leave a Comment