public void onApplicationEvent(ContextClosedEvent event) { ApplicationContext ac = event.getApplicationContext(); DeviceService deviceService = (DeviceService) ac.getBean("deviceService"); DalClient dalClient = (DalClient) ac.getBean("dalClient"); // SimpMessagingTemplate template = () deviceService.exit(); LogPo systemLogDto = new LogPo("服务器已停止运行"); dalClient.persist(systemLogDto); LOGGER.info("deviceService.exit() has been called"); }
@Override public void onApplicationEvent(ContextClosedEvent event) { if (this.applicationContext == event.getApplicationContext()) { this.contextStopped = true; } }