由於項目中有多個定時任務,cron表達式在代碼裏面維護起來略顯困難,故將cron表達式寫在配置文件中。
application.properties:
1.配置文件
system.bEnableStatisticCurrentCron=1
相對代碼示例
@Scheduled(fixedDelayString = "${system.bEnableStatisticCurrentCron}")
2.配置文件
system.bEnableStatisticCurrentCron=10 0/5 * * * ?
相對代碼示例
@Scheduled(cron= "${system.bEnableStatisticCurrentCron}")