Multiple datasources migrations using Flyway in a Spring Boot application

后端 未结 4 534
刺人心
刺人心 2020-12-31 03:39

We use Flyway for db migration in our Spring Boot based app and now we have a requirement to introduce multi tenancy support while using multiple datasources strategy. As pa

4条回答
  •  余生分开走
    2020-12-31 04:02

    Having your same problem... I looked into the spring-boot-autoconfigure artifact for V 2.2.4 in the org.springframework.boot.autoconfigure.flyway package and I found an annotation FlywayDataSource.

    Annotating ANY datasource you want to be used by Flyway should do the trick.
    Something like this:

    @FlywayDataSource
    @Bean(name = "someDatasource")
    public DataSource someDatasource(...) {
            
    }
    

提交回复
热议问题