Fix JPA bootstrap executor detection with multiple candidates

Spring Boot provides two separate auto-configurations that can
potentially expose an `AsyncTaskExecutor` implementation so relying on
the presence of a single instance is too weak.

This commit fixes the detection of the AsyncTaskExecutor that can be
used to bootstrap JPA so that a single instance is used and, in the case
more than one exists, the one named `applicationTaskExecutor`.

Closes gh-15447
This commit is contained in:
Stephane Nicoll
2019-01-07 14:54:59 +01:00
parent d4992777b9
commit 830da28b8c
3 changed files with 78 additions and 14 deletions

View File

@@ -3840,7 +3840,8 @@ Spring Data JPA repositories support three different modes of bootstrapping: def
deferred, and lazy. To enable deferred or lazy bootstrapping, set the
`spring.data.jpa.repositories.bootstrap-mode` to `deferred` or `lazy` respectively. When
using deferred or lazy bootstrapping, the auto-configured `EntityManagerFactoryBuilder`
will use the context's async task executor, if any, as the bootstrap executor.
will use the context's `AsyncTaskExecutor`, if any, as the bootstrap executor. If more
than one exists, the one named `applicationTaskExecutor` will be used.
TIP: We have barely scratched the surface of Spring Data JPA. For complete details, see
the https://docs.spring.io/spring-data/jpa/docs/current/reference/html/[Spring Data JPA