1

我在 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为它才能工作?

4

1 回答 1

0

如果您在单例 bean 上的所有销毁方法上调用registerShutdownHook方法,则调用ConfigurableApplicationContext

于 2018-04-05T10:00:38.080 回答