Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Asynchronous EntityManagerFactory bootstrapping to complete on context refresh completion [SPR-17334] #21868
I've attached a small example that hopefully illustrates the problem. When imported into your IDE and run,
Affects: 4.3.19, 5.0.9, 5.1 GA
Reference URL: spring-projects/spring-boot#14658
Juergen Hoeller commented
This is meant to be by design: The application and its web endpoints can be up and listening already while the persistence provider is still bootstrapping, only blocking once a request comes in that actually needs to access the persistence provider.
That said, I can see the issue with post-bootstrapping logic here. I guess we could try to attach a callback to the async bootstrap thread there, or we could have a mode of bootstrapping where we effectively wait and block at the end of the refresh phase.
Andy Wilkinson commented
Ah, I see. And that will of course work fine if you only access the database via the entity manager. It remains problematic for applications that aren't purely using JPA and are using
The area of Boot that led me to investigate this was
As things stand, even with our (ab)use of the