mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
Previously, the `entityManagerFactoryBuilder` bean method injected a `Map<String, AsyncTaskExecutor>` to determine the fallback executor used for background JPA bootstrapping. A `Map` parameter is resolved eagerly, so this forced early initialization of every `AsyncTaskExecutor` bean whenever the builder was created, even when background bootstrapping was not in use. When an `AsyncTaskExecutor` directly or transitively depended on the `EntityManagerFactory`, this resulted in a `BeanCurrentlyInCreationException`. The fallback executor is now resolved lazily. `EntityManagerFactoryBuilder` holds a `Supplier` that is only invoked when background bootstrapping is actually required, and the executor is then looked up from the `BeanFactory` rather than eagerly injected. A new `Supplier`-based constructor is added for this purpose; the existing constructor that accepts an `AsyncTaskExecutor` is retained and delegates to it. The same eager `Map<String, AsyncTaskExecutor>` injection, along with an unused private method, is also removed from `DataJpaRepositoriesAutoConfiguration`. See gh-50801 Signed-off-by: Ns <397827222@qq.com>