piotrek
piotrek

Reputation: 14550

Spring boot and flyway integration - init order

I have an EntityManager (and a DataSource) created by spring boot and i want to add flyway. but EntityManager must be created after flyway and flyway after the DataSource. do i have to create whole EntityManager manually only to add 'depends-on' or is there some simpler way?

Upvotes: 1

Views: 3460

Answers (2)

Dave Syer
Dave Syer

Reputation: 58094

The problem is in the usage of spring.jpa.hibernate.ddl-auto=validate (Hibernate wants to validate the DataSource before the migrations are executed, see here). A simple workaround is to switch to spring.jpa.hibernate.ddl-auto=none.

Upvotes: 1

Dave Syer
Dave Syer

Reputation: 58094

Boot doesn't create a Hibernate SessionFactory so probably you mean a JPA EntityManager. If you create your own Flyway it will always be initialized before the Boot autoconfig beans. Is that not what you see? Maybe you need to share a project.

Upvotes: 1

Related Questions