我在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
才能使其生效?
答案 0 :(得分:0)
如果在registerShutdownHook
上调用ConfigurableApplicationContext
方法,则会调用单个bean上的所有销毁方法