spring quartz

spring 3.xx 和 quartz 2.xx是不兼容的,自己使用的是 quzrtz1.6的

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation=" 
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd 
          http://www.springframework.org/schema/aop 
          http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" default-autowire="byName">
	 	
	 	<!-- 要调用的工作类  系统自动随机增加2—3个-->
        <bean id="quartzJob" class="com.wokejia.zxnews.util.TaskAutoSignUp">
        	<property name="initValue" value="60" />
        	<property name="minValue" value="2" />
        	<property name="maxValue" value="3" />
        </bean>
        <!--系统自动随机增加5-10个 -->
        <bean id="quartzJob2" class="com.wokejia.zxnews.util.TaskAutoSignUp">
        	<property name="initValue" value="60" />
        	<property name="minValue" value="5" />
        	<property name="maxValue" value="10" />
        </bean>
        <!--  系统随机增加4-6个; -->
        <bean id="quartzJob3" class="com.wokejia.zxnews.util.TaskAutoSignUp">
        	<property name="initValue" value="60" />
        	<property name="minValue" value="4" />
        	<property name="maxValue" value="6" />
        </bean>
        
        <!-- 定义调用对象和调用对象的方法 -->
        <bean id="jobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="targetObject"><ref bean="quartzJob"/></property>
            <property name="targetMethod"><value>saveStatistics</value></property>
        </bean>
        <bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="jobDetail"><ref bean="jobtask"/></property>
            <!--   0点-9点,22-24时,共11个小时,该时段每十分钟 -->
            <property name="cronExpression"><value>0 0/10 0-8,22-23 * * ?</value></property>
        </bean>
        
        <bean id="jobtask2" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="targetObject"><ref bean="quartzJob2"/></property>
            <property name="targetMethod"><value>saveStatistics</value></property>
        </bean>
        <bean id="doTime2" class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="jobDetail"><ref bean="jobtask2"/></property>
            <!--  9-10:30点,12:00-14:00,19:00-22:00点,共6.5个小时,该时段每五分钟 -->
            <property name="cronExpression"><value>0 0/5 9,12-13,19-21 * * ?</value></property>
        </bean>
        
        <bean id="jobtask3" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="targetObject"><ref bean="quartzJob3"/></property>
            <property name="targetMethod"><value>saveStatistics</value></property>
        </bean>
        <bean id="doTime3" class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="jobDetail"><ref bean="jobtask3"/></property>
            <!-- 10:30-12:00、14:00-19:00时,6.5个小时,该时间段每十分钟 -->
            <property name="cronExpression"><value>0 0/10 10-11,14-18 * * ?</value></property>
        </bean>
        
        <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序  -->
        <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
                <list>
                    <ref bean="doTime"/>
                    <ref bean="doTime2"/>
                    <ref bean="doTime3"/>
                </list>
            </property>
        </bean>    
</beans>

你可能感兴趣的:(spring quartz)