springboot動態設置定時任務Cron參數表達式

由於項目中有多個定時任務,cron表達式在代碼裏面維護起來略顯困難,故將cron表達式寫在配置文件中。

application.properties:

1.配置文件
    system.bEnableStatisticCurrentCron=1
相對代碼示例
    @Scheduled(fixedDelayString = "${system.bEnableStatisticCurrentCron}")

2.配置文件
    system.bEnableStatisticCurrentCron=10 0/5 * * * ?
相對代碼示例
    @Scheduled(cron= "${system.bEnableStatisticCurrentCron}")

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章