springboot cron定时任务配置

1、开启定时任务

开启定时任务比较简单,在入口出打开 @EnableScheduling

2、任务代码实现

其中

cron ="${thread.check.interval}

是配置在application.yml中:

扫描二维码关注公众号,回复: 13415451 查看本文章

项目运行后可看到控制台每秒打印:

cron常用
* * * * * * *
1 秒(0~59)
2 分钟(0~59)
3 小时(0~23)
4 天(0~31)
5 月(0~11)
6 星期(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT)
7.年份(1970-2099)
例如每秒钟:
" */1 * * * * *"
每天中午12点:
“0 0 12 * * ? " 每天中午12点触发

猜你喜欢

转载自blog.csdn.net/XJF199001/article/details/121130575