@Schedule注解中的Cron表达式读取properties的方法

1、properties文件中增加配置项:

datasync.cron=0 */10 * * * ?

2、定时任务类增加PropertySource注解:

@PropertySource("classpath:/xxxx.properties")

3、定时任务方法的Shedule注解改为:

@Scheduled(cron = "${datasync.cron}")

 

posted @ 2019-04-03 23:16  oliverreal  阅读(3091)  评论(0编辑  收藏  举报