springboot启动执行任务

springboot启动执行任务_第1张图片
代码

@Component
@Order(value = 1)
@Log4j2
public class LiftProcessor implements CommandLineRunner{
    
    @Autowired
    private ISmartsiteLiftDeviceService deviceService;
    @Autowired
    private ISmartsiteLiftWorkcycService workcycService;
    @Autowired
    private ISmartsiteLiftDataService liftDataService;

    @Override
    public void run(String... args) throws Exception {
        log.info(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作<<<<<<<<<<<<<");
        MqttLift mqttLift = new MqttLift();
        mqttLift.initMqttLift();
        while (true) {
            deviceService.pushDevice();
            workcycService.pushLiftWorkcyc();
            liftDataService.pushLiftData();
            try {
                Thread.sleep(480000);
            } catch (InterruptedException e) {
                log.error("Lift run error",e);
            }
        }
        
    }

}

你可能感兴趣的:(springboot升级版本)