SpringBoot 定时任务的使用
来源:互联网 发布:淘宝sop搜索 编辑:程序博客网 时间:2024/06/04 04:43
(本内容是综合网上的几篇文章的结果)
相关的注解
一共有两个,
@Scheduled–注解在定时任务方法上(有文章说方法所在的class必须是组件,Component或者Service)
@EnableScheduling–注解在Application上
@SpringBootApplication@EnableSchedulingpublic class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } }@Componentpublic class ScheduledTest { @Scheduled(cron="0 0/2 * * * ?") public void executeFileDownLoadTask() { // 间隔2分钟,执行任务 .... }}
定时基本参数
-fixedDelay 两次定时任务之间的间隔时间,单位毫秒
-fixedRate 通常意义上的定时间隔时间,如果本次任务的执行超过了这个时间,那么结束后就会立即执行下一次任务,单位毫秒
-initialDelay 延时设定的时间后再执行第一次任务,和上面两个参数组合使用,单位毫秒。
-cron 通过cron的方式来设置定时时间。
cron参数详解
参看第二篇引用的文章
引用文章
- SpringBoot Schedule 配置
- Spring 定时任务之 @Scheduled cron表达式
阅读全文
0 0
- springboot定时任务的使用
- SpringBoot 定时任务的使用
- SpringBoot定时任务的使用
- springboot定时任务使用
- springboot使用定时任务、异步
- SpringBoot定时任务的设置
- 二、springboot项目的简单使用之:定时任务
- Springboot 之 使用Scheduled做定时任务
- eclipse 使用maven构建springboot+定时任务
- Springboot使用定时任务,Spring Schedule
- SpringBoot 使用Scheduled 定时任务入门
- Springboot使用定时任务,Spring Schedule
- Springboot之使用Scheduled做定时任务
- SpringBoot定时任务说明
- springboot定时任务
- springboot(九):定时任务
- springboot(九):定时任务
- springboot 定时任务
- iOS 07-线程安全 同步锁
- 机器学习第八周(一)--K-means
- erlang游戏服务器
- C/C++中memset函数
- 【干货分享】大数据开发套件DataIDE使用教程
- SpringBoot 定时任务的使用
- 安装ruby
- 15
- crontab记录的日志时间与系统时间不一致
- Nand ECC了解
- STM32-custom usb
- 细粒度识别中的深度定位与对齐
- 数据结构Java实现07----队列:顺序队列&顺序循环队列、链式队列、顺序优先队列
- do while和while的区别