Spring任务调度 task:scheduled-tasks
2017-07-08 18:15
525 查看
spring内部有一个task是Spring自带的一个设定时间自动任务调度,task使用的时候很方便,但是他能做的东西不如quartz那么的多!
可以使用注解和配置两种方式,配置的方式如下
ref是工作类
method是工作类中要执行的方法
initial-delay是任务第一次被调用前的延时,单位毫秒
fixed-delay是上一个调用完成后再次调用的延时
fixed-rate是上一个调用开始后再次调用的延时(不用等待上一次调用完成)
cron是表达式,表示在什么时候进行任务调度。
第一个任务表示程序启动5s后调用clearJob类中的execute方法,然后每隔一个小时再调用execute一次
第三个任务表示每天的23点59分调用statJob类中的statLgj方法
可以使用注解和配置两种方式,配置的方式如下
<task:scheduled-tasks> <task:scheduled ref="clearJob" method="execute" initial-delay="5000" fixed-delay="3600000"/> <task:scheduled ref="listenJob" method="execute" initial-delay="5000" fixed-delay="5000"/> <task:scheduled ref="statJob" method="statLgj" cron="0 59 23 * * ?"/> <task:scheduled ref="statJob" method="statBadNameAndQQ" cron="23 28 20 * * ?"/> </task:scheduled-tasks>
ref是工作类
method是工作类中要执行的方法
initial-delay是任务第一次被调用前的延时,单位毫秒
fixed-delay是上一个调用完成后再次调用的延时
fixed-rate是上一个调用开始后再次调用的延时(不用等待上一次调用完成)
cron是表达式,表示在什么时候进行任务调度。
第一个任务表示程序启动5s后调用clearJob类中的execute方法,然后每隔一个小时再调用execute一次
第三个任务表示每天的23点59分调用statJob类中的statLgj方法
相关文章推荐
- Spring的定时任务(任务调度)<task:scheduled-tasks>
- Spring任务定时调度<task:scheduled-tasks>cron参数详解
- 关于Spring任务调度<task:scheduled-tasks>的cron参数详解
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】 (转载)
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- Spring之ScheduledExecutorTask任务调度
- 利用 spring 的 task:scheduled-tasks 执行定期任务
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- Spring任务调度<task:scheduled-tasks>【含cron参数详解】
- Spring整合TimerTask实现定时任务调度
- Spring任务调度Scheduling Tasks
- Spring任务调度之Spring-Task
- Spring的两种任务调度Scheduled和Async
- Spring3.0.6定时任务task:scheduled
- spring timetask 定时任务调度
- Spring3.0.6定时任务task:scheduled
- Spring3.0.6定时任务task:scheduled
- Spring ScheduledTimerTask 定时任务执行