转载:https://blog.csdn.net/m0_37202351/article/details/86255132
直接上代码,将service改为static静态,就可以注入成功
private static BaiDuVoiceConfig config;
@Autowired
public void setConfig(BaiDuVoiceConfig config) {
DqSocketMessage.config = config;
}
private static DqMessageService service;
@Autowired
public void setService(DqMessageService service) {
DqSocketMessage.service = service;
}
原因就是:spring管理的都是单例(singleton)和 websocket (多对象)相冲突
记录一下,方便各位以后少走弯路。