springboot项目中同时使用websocket,自带定时任务@Scheduled启动项目时报错
Application run failed
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘defaultSockJsTaskScheduler’ is expected to be of type ‘org.springframework.scheduling.TaskScheduler’ but was actually of type ‘org.springframework.beans.factory.support.NullBean’
产生原有:两者冲突
解决办法:增加配置文件
@Configuration
public class ScheduledConf {
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduling = new ThreadPoolTaskScheduler();
scheduling.setPoolSize(10);
scheduling.initialize();
return scheduling;
}
}