异步事件侦听器的默认 TaskExecutor 实现

Default TaskExecutor implementation for Async event listeners

我正在使用基于注释的事件侦听器,我也将其标记为 @Async。 (参见 Asynchronous Listeners)。

Spring 使用哪个 TaskExecutor 实现来满足这些请求? The documentation 读取:

By default, when specifying @Async on a method, the executor that is used is the one configured when enabling async support, i.e. the “annotation-driven” element if you are using XML or your AsyncConfigurer implementation, if any.

问题是我根本没有为此任何配置,所以我不确定我的AsyncConfigurer实施是从什么开始的。

我的猜测是我们正在处理SimpleAsyncTaskExecutor

我在 the documentation 中找到了 EnableAsync 的答案:

By default, Spring will be searching for an associated thread pool definition: either a unique TaskExecutor bean in the context, or an Executor bean named "taskExecutor" otherwise. If neither of the two is resolvable, a SimpleAsyncTaskExecutor will be used to process async method invocations.

所以,这是 SimpleAsyncTaskExecutor