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

Posted oliverreal

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了@Schedule注解中的Cron表达式读取properties的方法相关的知识,希望对你有一定的参考价值。

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

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

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

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

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

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

 

以上是关于@Schedule注解中的Cron表达式读取properties的方法的主要内容,如果未能解决你的问题,请参考以下文章