Skip to content

Document that applicationTaskExecutor can also act as bootstrapExecutor if the latter is not explicitly configured #45232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The auto-configured javadoc:org.springframework.core.task.AsyncTaskExecutor[] is
- Support for blocking execution in Spring WebFlux.
- Utilized for inbound and outbound message channels in Spring WebSocket.
- Acts as a bootstrap executor for JPA, based on the bootstrap mode of JPA repositories.
- Used as `bootstrapExecutor` for parallel bean initialization during startup, unless a `bootstrapExecutor` bean is defined.

While this approach works in most scenarios, Spring Boot allows you to override the auto-configured javadoc:org.springframework.core.task.AsyncTaskExecutor[].
By default, when a custom javadoc:java.util.concurrent.Executor[] bean is registered, the auto-configured javadoc:org.springframework.core.task.AsyncTaskExecutor[] backs off, and the custom javadoc:java.util.concurrent.Executor[] is used for regular task execution (via javadoc:org.springframework.scheduling.annotation.EnableAsync[format=annotation]).
Expand All @@ -31,6 +32,12 @@ include-code::application/MyTaskExecutorConfiguration[]
The `applicationTaskExecutor` bean will also be used for regular task execution if there is no javadoc:org.springframework.context.annotation.Primary[format=annotation] bean or a bean named `taskExecutor` of type javadoc:java.util.concurrent.Executor[] or javadoc:org.springframework.scheduling.annotation.AsyncConfigurer[] present in the application context.
====

[NOTE]
====
The `applicationTaskExecutor` bean will be used for background bootstrapping if a bean named `bootstrapExecutor` is not defined.
Spring Boot registers an alias for the `applicationTaskExecutor` bean with the name `bootstrapExecutor` if a `bootstrapExecutor` bean is not already defined and `applicationTaskExecutor` is present in the context.
====

[WARNING]
====
If neither the auto-configured `AsyncTaskExecutor` nor the `applicationTaskExecutor` bean is defined, the application defaults to a bean named `taskExecutor` for regular task execution (javadoc:org.springframework.scheduling.annotation.EnableAsync[format=annotation]), following Spring Framework's behavior.
Expand Down Expand Up @@ -80,6 +87,7 @@ These integrations include:
- Spring WebFlux's blocking execution support.
- Utilized for inbound and outbound message channels in Spring WebSocket.
- Acts as a bootstrap executor for JPA, based on the bootstrap mode of JPA repositories.
- Used as the `bootstrapExecutor` for parallel bean initialization during startup, unless a `bootstrapExecutor` bean is explicitly provided.

[TIP]
====
Expand Down