spring与quart整合实现任务调度_学习笔记

spring与quart整合实现任务调度


quartz-1.8.5.jar 
commons-logging.jar 
spring-core-3.0.5.RELEASE.jar 
spring-beans-3.0.5.RELEASE.jar 
spring-context-3.0.5.RELEASE.jar 
spring-context-support-3.0.5.RELEASE.jar 
spring-asm-3.0.5.RELEASE.jar 
spring-expression-3.0.5.RELEASE.jar 
spring.transaction-3.0.5.RELEASE.jar 
spring-web-3.0.5.RELEASE.jar 


有两种方法实现任务
 第一种是实现job
<bean id="myjob" class="org.springframework.scheduling.quartz.JobDetailBean">


第二种是可以不用实现接job接口,通过targetMethod指定方法
<bean id="testJob" class="cn.yue.testJob" />
<bean id="synchronousaccountTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="testJob" />
</property>
<property name="targetMethod">
<value>mathodName</value>
</property>
<!-- 如果配置多项该项设为true,则允许并发 -->
<property name="concurrent" value="true"/>
</bean>


<!--触发器-->
<bean id="taskref" class="cn.yue.taskref">
<bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="taskName" ref="taskref"></property>
<!-- 时间设置-->
<property name="cronExpression" value="0 20 5,23 * * ?"></property>
</bean>
<!--调度工厂来管理触发器-->
<bean id="SpringJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
    <property name="triggers">  
        <list>  
            <ref bean="CronTriggerBean"/>  
        </list>  
    </property>  
</bean>

你可能感兴趣的:(spring与quart整合实现任务调度_学习笔记)