springboot websocket service注入失败
2018-11-28 本文已影响1人
织梦少年666
在websocket里面,注入service进行数据库操作时,service为空注入失败
image.pngConfigurableApplicationContext run = SpringApplication.run(QuantradingCollectApplication.class, args);
WebSocketMarket.setAllpicationContext(run);
image.png
private HistoryDataMinService historyDataMinService;
private static ApplicationContext allpicationContext;
public static void setAllpicationContext(ApplicationContext context){
allpicationContext = context;
}
image.png
historyDataMinService = (HistoryDataMinService) allpicationContext.getBean(HistoryDataMinService.class);
image.png
image.png