-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
Hey Spring Boot Team,
I already reported this in the spring-data-jpa repository (see spring-projects/spring-data-jpa#3959), but was sent here. I'm facing a circular dependency problem using Flyway Java-based migrations. This issue has also been discussed in flyway/flyway#1062 (comment).
If you're initializing Flyway Java-based migrations as Spring Beans, they're injected into the Flyway instance using Spring's DI mechanism. This can be found in FlywayAutoConfiguration.
Since the Java-based migrations are Spring Beans themselves, you can inject other beans. If those beans are somehow associated with JPA, the application fails on startup because a circular dependency between the EntityManagerFactory
and Flyway
is detected. This dependency between database initializing beans and dependent beans is documented here.
I've created a minimal example that shows this issue. Is this the desired behavior? In flyway/flyway#1062 there is a suggested workaround, but it feels like missing the point having Java-based migrations as Spring beans and not being able to use the JPA layer out of the box.
Best Regards Leon