Springboot创建定时任务(可配置)

@ApiModel("***定时任务")
@Component
@Configuration
@EnableScheduling
//@PropertySource("classpath:/***") // 可指定配置文件
public class MatchOpenCheckScheduledTask { private final Logger log = LoggerFactory.getLogger(this.getClass()); @Scheduled(cron = "${open-check.cron}") public void openCheckTask(){ log.info("执行‘自动匹配开通校验’定时任务开始:" + FlowUtil.getCurrentDate("yyyy-MM-dd HH:mm:ss") ); long startTime = System.currentTimeMillis(); //获取开始时间   /**********************************************************************************************/


  /**********************************************************************************************/

long endTime = System.currentTimeMillis(); //获取结束时间 log.info("执行‘自动匹配开通校验’定时任务结束:" + FlowUtil.getCurrentDate("yyyy-MM-dd HH:mm:ss") ); log.info("执行时间:"+(endTime - startTime)/1000+" 秒"); }

 

在线Cron表达式生成器

    https://cron.qqe2.com/

 

posted @ 2020-12-19 23:47  丿小师傅灬  阅读(1072)  评论(0编辑  收藏  举报