spring注解@Scheduled中fixedDelay、fixedRate和cron表达式的区别
来源:互联网 发布:重庆邮电大学就业知乎 编辑:程序博客网 时间:2024/06/08 10:43
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"><context:component-scan base-package="com.test.*"/><!--需要扫描的包--><task:annotation-driven/> <!-- 这句是重点 定时器开关--></beans>
添加task定时任务的xml文件,配置在spring文件中
@Scheduled注解可以控制方法定时执行,其中有三个参数可选择:
1、fixedDelay控制方法执行的间隔时间,是以上一次方法执行完开始算起,如上一次方法执行阻塞住了,那么直到上一次执行完,并间隔给定的时间后,执行下一次。
2、fixedRate是按照一定的速率执行,是从上一次方法执行开始的时间算起,如果上一次方法阻塞住了,下一次也是不会执行,但是在阻塞这段时间内累计应该执行的次数,当不再阻塞时,一下子把这些全部执行掉,而后再按照固定速率继续执行。
3、cron表达式可以定制化执行任务,但是执行的方式是与fixedDelay相近的,也是会按照上一次方法结束时间开始算起。
具体使用方法参看使用Spring的@Scheduled实现定时任务
阅读全文
0 0
- spring注解@Scheduled中fixedDelay、fixedRate和cron表达式的区别
- spring中使用@Scheduled注解时corn表达式、fixedRate、fixedDelay的区别
- 一张图让你秒懂Spring @Scheduled定时任务的fixedRate,fixedDelay,cron执行差异
- 理解 Spring 定时任务的 fixedRate 和 fixedDelay 的区别
- java鬼混笔记:springboot 5、springboot的Scheduled定时器:fixedDelay和fixedRate区别
- spring @Scheduled cron表达式
- Spring定时任务之@Scheduled注解(cron表达式详解)
- Spring定时任务注解标签-- @Scheduled之cron表达式
- 定时任务之Spring中@Scheduled cron表达式
- spring 3.0 中 @Scheduled cron表达式需要注意的几个地方
- @Scheduled注解 定时任务 cron表达式详解
- Scheduled注解 定时任务 cron表达式详解
- @Scheduled注解 定时任务 cron表达式
- springBoot @Scheduled注解 cron表达式详解
- Spring定时任务注解@Scheduled(cron="*****?")
- Spring 定时任务之 @Scheduled cron表达式
- Spring 定时任务之 @Scheduled cron表达式
- spring 定时任务 scheduled Cron表达式
- JavaScript高阶函数map/reduce
- 源码编译安装mysql 5.7.12实操
- 1069. 微博转发抽奖(20)
- 这些贷款不成文定律,你都造吗?
- Android 响应式编程 RxJava2 解析
- spring注解@Scheduled中fixedDelay、fixedRate和cron表达式的区别
- 综合练习之--1、复用布局页面显示XLV 和 侧滑 vp效果
- eclipse搭建JSF简单示例的教程(亲测)
- 值类型和引用类型误区
- 使用webstorm操作git
- display: inline-block换行问题
- Android使用OKHttp3实现下载(断点续传、显示进度)
- JavaScript的this机制与箭头函数(一)——this绑定的4种机制
- java代码实现对数据库的备份操作