由于项目中有多个定时任务,cron表达式在代码里面维护起来略显困难,故将cron表达式写在配置文件中。
application.properties:
1.配置文件
system.bEnableStatisticCurrentCron=1
相对代码示例
@Scheduled(fixedDelayString = "${system.bEnableStatisticCurrentCron}")
2.配置文件
system.bEnableStatisticCurrentCron=10 0/5 * * * ?
相对代码示例
@Scheduled(cron= "${system.bEnableStatisticCurrentCron}")