I have created Spring application. Pom xml is attached.
It has a config like this (below) and some db/migration/V1__init.sql for Flyway db migration tool.
It
This works for me with Spring Boot 2.3.1
1- you need to disable boot for Flyway, by insert into resources/application.properties:
spring.flyway.enabled = false
2- Start your migration scripts from version 2 as V1 is used as a baseline, V1 file will be ignored.
3- Make the @SpringBootApplication class implements CommandLineRunner interface (It is used to execute the code after the Spring Boot application started ). and it will be like this:
@SpringBootApplication
public class SpringBootApplication implements CommandLineRunner {
@Autowired
DataSource dataSource;
public static void main(String[] args) {
SpringApplication.run(SpringBootApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
Flyway.configure().baselineOnMigrate(true).dataSource(dataSource).load().migrate();
}
}
This answer helped me