springboot在整合websocket出现一下报错:
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'
解决方案
添加一个定时任务的配置类来创建一个ThreadPoolTaskScheduler对象。
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;/*** @author 寅灯* @version 3.0*/
@Configuration
public class ScheduledConfig {@Beanpublic TaskScheduler taskScheduler() {ThreadPoolTaskScheduler scheduling = new ThreadPoolTaskScheduler();scheduling.setPoolSize(20);scheduling.initialize();return scheduling;}}