springboot动态设置定时任务Cron参数表达式

由于项目中有多个定时任务,cron表达式在代码里面维护起来略显困难,故将cron表达式写在配置文件中。

application.properties:

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

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

 

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