spring整合quartz任务调度框架使用

调度器

<bean autowire="no"  
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
        <property name="triggers">  
            <list>  
                <ref local="cron1" /> 
            </list>  
        </property>  
    </bean>

计划器

<bean id="cron1" class="org.springframework.scheduling.quartz.CronTriggerBean">  
        <property name="jobDetail">  
            <ref bean="Job1" />  
        </property>  
        <property name="cronExpression">  
            <value>0 0 2 * * ?</value>  
        </property>  
    </bean>

任务

<bean id="emailNofityJob" class="com.demo.task.EmailNofityJob"></bean>   

    <bean id="Job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
        <property name="targetObject">  
            <ref local="emailNofityJob" />  
        </property>  
        <property name="targetMethod">  
            <!--  要执行的方法名称  -->  
            <value>sendNofity</value>  
        </property>  
    </bean>

相关推荐