springboot websocket service注入失败

作者: 织梦少年666 | 来源:发表于2018-11-28 17:14 被阅读1次

在websocket里面,注入service进行数据库操作时,service为空注入失败

image.png
ConfigurableApplicationContext 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

相关文章

网友评论

    本文标题:springboot websocket service注入失败

    本文链接:https://www.haomeiwen.com/subject/xsjzqqtx.html