expected to be of type ‘org.springframework.scheduling.TaskScheduler‘ but was actually of NullBean
时间:2025-06-24 12:23:54 来源:新华社
【字体:  

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'

解决方案。

添加定时任务的配置类,创建ThreadPolTaskScheduler对象。

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。{ 。ThreadPoolTaskScheduler。scheduling。 =new。ThreadPoolTaskScheduler。(。)。;scheduling。.。setPoolSize。(。20。)。;scheduling。.。initialize。(。)。;return。scheduling。;}。}。

[责任编辑:百度一下]
检察日报数字报 | 正义网 |
Copyrights©最高人民检察院 All Rights Reserved.