Spring结合任务调度quartz

来源:互联网 发布:苹果打碟软件 编辑:程序博客网 时间:2024/05/16 08:23
<!-- 自动更新任务 -->
    <bean id="templateJob" class="项目名.service.impl.xxxJob"></bean>
    <bean id="xxxMethodJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref local="templateJob" />
        </property>
        <property name="targetMethod">
            <value>xxxMethodJob</value>
        </property>
        <property name="concurrent" value="false" />
    </bean>
    <bean id="xxxMethodJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="xxxMethodJob" />
        </property>
        <property name="cronExpression">
            <value>0 0 0 1 */3 ?</value>
        </property>
    </bean>
    
    <!-- Job管理 -->
    <bean id="quartzBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton">
        <property name="triggers">
            <list>
                <ref local="xxxMethodJobTrigger" />
            </list>
        </property>
    </bean>
    
    <bean id="quartzManagerService" class="项目名.service.impl.QuartzManagerServiceImpl">
        <property name="scheduler" ref="quartzBean" />
    </bean>
原创粉丝点击