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
Spring Boot auto-configuration of Flyway ensures that database migrations have run before Hibernate is initialised. In other words, you can't rely on Flyway auto-configuration and use Flyway to populate tables created by Hinernate.
One solution is to fully embrace Flyway and use it to both create the tables and populate them. You can then switch off Hibernate's table creation (spring.jpa.hibernate.ddl-auto=none
). This approach is more robust as it will allow your database to evolve more easily. This is what I would recommend that you do.
Another solution is to disable auto-configuration of Flyway (flyway.enabled=false
) and to configure it your self. You can then configure Flyway to depend on Hibernate so that Hibernate has created the tables before Flyway tries to populate them.