SpringBoot极简教程 · Spring Boot Springboot所学所写

springboot websocket service注入失败

2018-11-28  本文已影响1人  织梦少年666

在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
上一篇下一篇

猜你喜欢

热点阅读