【发布时间】:2018-04-05 08:15:35
【问题描述】:
我在 Spring 4 中有以下 annotationconfig
@Bean(name = "replicationThreadExecutor")
public Executor replicationThreadExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(threadPoolCoreSize);
executor.setMaxPoolSize(threadPoolCoreSize);
executor.initialize();
return executor;
}
我关心的是Executor 的破坏。 Spring 会认识到 Executor 的动态类型是 DisposableBean 的一个实例并销毁它,还是我需要将返回类型更改为 ThreadPoolTaskExecutor 才能工作?
【问题讨论】:
-
作为基于 Java 的配置的经验法则,尽可能具体,因为在创建应用程序上下文时检查这些配置。因此,在这种情况下,可能是未注册回调(尽管
DisposableBean可能会起作用)。
标签: spring spring-annotations spring-async