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>
Replace `PropertyBasedRequiredBackgroundBootstrapping` with a simpler
`BootstrapExecutorRequiredException` and use a regular failure analyzer
to provide help.
See gh-49733
See gh-49688
Update `spring.data.jpa.repositories.bootstrap-mode` logic
so that:
- A value of `lazy` no longer sets a bootstrap executor.
- A value of `deferred` requires that a bootstrap executor is
ultimately set, and fails with a meaningful message if it is
not.
The logic used to find the AsyncTaskExecutor has now moved to
the `JpaBaseConfiguration` and is triggered by the
`EntityManagerFactoryBuilder` only when background
bootstrapping is required.
Closes gh-49688
This commit adds a spring-boot-persistence module with data technology
independent features. This provides a better home for EntityScan and
PersistenceExceptionTranslationAutoConfiguration.
Closes gh-45328