你在用
@Scheduled
在Tomcat中生成线程。您必须确保这些线程在
ServletContext
URLConnection
不启动新线程来执行请求。
this answer
. 这可以通过定制来完成
taskScheduler
豆子:
@Configuration
@EnableScheduling
public class TaskConfiguration {
@Bean(destroyMethod = "shutdown")
public Executor taskScheduler() {
return Executors.Executors.newFixedThreadPool(4,
new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
}
});
}
}