spring-Quartz 配置举例

<?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:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd       
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
    
    <!--  要调用的工作类 -->
    <bean id="hourQuartzJob" class="com.anruy.test.report.quartz.HourQuartzJob"></bean>
        
    <bean id="hourJobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <!-- 调用的类 -->
        <property name="targetObject">
            <ref bean="hourQuartzJob"/>
        </property>
        <!-- 调用类中的方法 -->
        <property name="targetMethod">
            <value>work</value>
        </property>
        <property name="concurrent" value="false"/>
    </bean>
        
    <bean id="hourDoTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="hourJobtask"/>
        </property>
        <!-- cron表达式 -->
        <property name="cronExpression">
            <!--<value>00 30 * ? * *</value>-->
            <!--<value>秒       分     时  日   月  周  年</value>-->
            <value>00 30 * ? * * 2100</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="hourDoTime"/>
            </list>
        </property>
    </bean>
    


</beans>

 

posted on 2018-01-22 11:36  anruy  阅读(104)  评论(0)    收藏  举报

导航