[转]Spring配置多个不同的定时任务

Spring配置多个不同的定时任务
Spring, 任务
<!-- 不需要通知性能监控中心的任务 -->
        <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                <property name="targetObject" ref="loopDataSourceTask" />
                <property name="targetMethod" value="execute" />
        </bean>

             <bean id="jobDetail2" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
                <property name="targetObject" ref="loopDataSourceTask2" />
                <property name="targetMethod" value="execute" />
        </bean>
        <!-- 配置两个任务 每2、3分钟执行一次-->
        <bean id="appSubscTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
                <property name="jobDetail" ref="jobDetail" />
                <property name="cronExpression" value="0 0 0/2 * * ?"  />
        </bean>
               <bean id="appSubscTrigger2" class="org.springframework.scheduling.quartz.CronTriggerBean">
                <property name="jobDetail" ref="jobDetail2" />
                <property name="cronExpression" value="0 0 0/3 * * ?"  />
        </bean>

                <!-- 添加触发器 -->                
        <bean id="appStart" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">               
                <property name="triggers">
                <list>
                <ref local="appSubscTrigger" />
                <ref local="appSubscTrigger2" />
                </list>
                </property>
        </bean>               
        <!-- 执行任务的处理类 -->                
        <bean id="loopDataSourceTask" class="com.alisoft.space.apps.task.action.LoopDataSourceTask">               
        </bean>

               <bean id="loopDataSourceTask2" class="com.alisoft.space.apps.task.action.LoopDataSourceTask2">               
        </bean>

你可能感兴趣的:(spring)