spring task定时器笔记
定时器有两种方式
1.延迟启动
<bean id="timerTaskRunnerChain" class="bingo.uam.task.TimerTaskRunnerChain">
<property name="timerTasks">
<list>
<bean class="bingo.uam.task.XXXXTask"></bean>
</list>
</property>
</bean> <bean id="btBuildTimerTask"
class="org.springframework.scheduling.timer.ScheduledTimerTask">
<!-- 设置启动延迟 -->
<property name="delay">
<value>3600000</value> <!-- 1个小时后启动 -->
</property>
<!-- 后续延迟 -->
<property name="period">
<value>3600000</value>
</property>
<!-- 指定触发器信息 -->
<property name="timerTask">
<ref local="timerTaskRunnerChain" />
</property>
</bean> <!-- 使用TimerFactoryBean类,你可以让Spring使用配置创建触发器,并为一组指定的ScheduledTimerTask bean自动创建Timer实例。 -->
<bean id="timerFactory"
class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="btBuildTimerTask" />
</list>
</property>
</bean>
2.某个设定时刻启动
<!-- 配置Quartz, 用于凌晨2点启动 -->
<bean id="blogTimerTask" class="bingo.uam.task.XXXXTask"/>
<bean id="blogSchedulerJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="blogTimerTask"/>
<property name="targetMethod" value="run"/> <!--启动的方法 -->
<property name="concurrent" value="false"/>
</bean>
<bean id="blogCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean" >
<property name="jobDetail" ref="blogSchedulerJobDetail"/>
<property name="cronExpression">
<!-- 秒 分 时 日 月 年 -->
<value>0 0 2 * * ?</value> <!-- 每天两点启动 -->
</property>
</bean>
<bean id="blogSchedulerFactory" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="blogCronTrigger"/>
</list>
</property>
</bean>
spring task定时器笔记的更多相关文章
- spring task定时器的配置使用
spring task的配置方式有两种:配置文件配置和注解配置. 1.配置文件配置 在applicationContext.xml中增加spring task的命名空间: xmlns:task=&qu ...
- java Quartz定时器任务与Spring task定时的几种实现,
java Quartz定时器任务与Spring task定时的几种实现 基于java 的定时任务实现, Quartz 时间详细配置 请查阅 http://www.cnblogs.com/si ...
- spring task 配置
Spring对Quartz作了一个封装,同时,Spring自己也提供了一个任务定时器(spring-task),现把它总结一下. 对于Quartz,我们使用的时候主要是注重两个方面,一个是定时任 ...
- Quartz Spring与Spring Task总结
Spring对Quartz作了一个封装,同时,Spring自己也提供了一个任务定时器(spring-task),现把它总结一下. 对于Quartz,我们使用的时候主要是注重两个方面,一个是定时任 ...
- uartz Spring与Spring Task总结
Spring对Quartz作了一个封装,同时,Spring自己也提供了一个任务定时器(spring-task),现把它总结一下. 对于Quartz,我们使用的时候主要是注重两个方面,一个是定时任 ...
- Spring任务调度定时器
1.在spring-context.xml配置 <!-- 计划任务配置,用 @Service @Lazy(false)标注类,用@Scheduled(cron = "0 0 2 * * ...
- 任务调度的方式:Timer、ScheduledExecutorService、spring task、quartz、XXL-JOB、Elastic-Job
任务调度 定时任务调度:基于给定的时间点.给定的时间间隔.给定的执行次数自动执行的任务. Timer 介绍 Timer,简单无门槛,一般也没人用. Timer位于java.util包下,其内部包含且仅 ...
- 任务调度 Spring Task 4(一)
深入浅出spring task定时任务 在工作中有用到spring task作为定时任务的处理,spring通过接口TaskExecutor和TaskScheduler这两个接口的方式为异步定时任务提 ...
- java定时任务实现的几种方式(Timer、Spring Task、Quartz)
Timer JDK自带的Timer类,允许调度一个TimerTask任务. Demo: /** * Timer测试类 */ public class TimerDemo { public static ...
随机推荐
- 三种ViewController跳转的异同
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag comple ...
- fzu 2107 Hua Rong Dao(状态压缩)
Problem 2107 Hua Rong Dao Accept: 106 Submit: 197 Time Limit: 1000 mSec Memory Limit : 32768 K ...
- js实现无刷新表单提交文件,将ajax请求转换为form请求方法
最近在做项目的时候遇到一个需要上传文件的需求,因为ajax请求是无法上传二进制文件流的,所以只能用form表单提交,而form提交有一个问题就是会使页面刷新,本文解决了form表单提交文件时页面刷新的 ...
- debian7.1 sources.list
deb http://mirrors.163.com/debian wheezy main non-free contribdeb http://mirrors.163.com/debian whee ...
- Click Models for Web Search(2) - Parameter Estimation
在Click Model中进行参数预估的方法有两种:最大似然(MLE)和期望最大(EM).至于每个click model使用哪种参数预估的方法取决于此model中的随机变量的特性.如果model中的随 ...
- The Top 10 Javascript MVC Frameworks Reviewed
Over the last several months I have been in a constant search for the perfect javascript MVC framewo ...
- Django--BBS项目
需求 模仿抽屉()和虎嗅()做一个网站bbs 知识点 Django知识: models表字段第一个属性可以用 2 3 from django.contrib.auth.models import Us ...
- CSS布局 -- 左右定宽,中间自适应
左右定宽,中间自适应 有几种方法可以实现 改变窗口大小看看? 方案一: 左右设置绝对定位,定宽,中间设置margin-left margin-right 查看 demo <!DOCTYPE h ...
- ompparticles.cpp:(.text+0x322): undefined reference to `omp_set_num_threads'
参考 http://www.code-by.org/viewtopic.php?f=54&t=163
- ok6410 android driver(12)
In this essay, I will talk about how to write the service libraries. TIPS : I won't discuss the name ...