您的位置:首页 > 编程语言 > Java开发

Spring结合任务调度quartz

2017-09-01 16:36 399 查看
<!-- 自动更新任务 -->

    <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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: