zoukankan      html  css  js  c++  java
  • Spring Quartz定时调度任务配置

    applicationContext-quartz.xml定时调度任务启动代码:

    <?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:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/aop 
               http://www.springframework.org/schema/aop/spring-aop.xsd
               http://www.springframework.org/schema/tx 
               http://www.springframework.org/schema/tx/spring-tx.xsd"
        default-lazy-init="false">
        
        <bean id="scheduleInfoManager" class="com.web.scheduler.util.QuartzJobFactory">
            <property name="scheduler" ref="schedulerFactory" />
            <property name="jobService"></property>
        </bean>
        
        <bean id="schedulerJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">    
             <property name="group" value="job_work"/>
             <property name="name" value="job_work_name"/>
             <property name="targetObject" ref="scheduleInfoManager"/>    
             <property name="targetMethod" value="execute"/>    
             <property name="concurrent" value="false"/>    
        </bean>  
        
        <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean ">
            <property name="name" value="work_default_name"/>
            <property name="group" value="work_default"/>
            <property name="jobDetail" ref="schedulerJobDetail" />
            <property name="cronExpression">
                <value>0 0 2 * * ?</value>
            </property>
        </bean>
        
        <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <property name="triggers">
                <list>
                    <ref bean="cronTrigger" />
                </list>
            </property>
        </bean>
    </beans>

    <!-- 在spring appcontext中引入后定时调度才会有效 -->
    <import resource="classpath:applicationContext-quartz.xml" />

  • 相关阅读:
    唤醒控件曾经拥有的能力(重新继承是可以使用的.)
    为ASP.NET MVC应用程序创建更复杂的数据模型
    Akka入门实例
    最火的.NET开源项目(转)
    Roslyn 编译平台概述
    C#开发157
    ASP.NET MVC学习之控制器篇
    AngularJS中数据双向绑定(two-way data-binding)
    订单系统中并发问题和锁机制的探讨
    Visual Studio 编辑器
  • 原文地址:https://www.cnblogs.com/yzuzhang/p/5127150.html
Copyright © 2011-2022 走看看