zoukankan      html  css  js  c++  java
  • spring_quartz的实现

    一.在spring配置文件中引用对应的定时任务配置文件

    二.定义定时任务的业务代码

    三.配置定时任务配置文件spring-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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!--增加线程池-->
    <bean id="executor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="10" />
    <property name="maxPoolSize" value="100" />
    <property name="queueCapacity" value="500" />
    </bean>

    <!--定义业务逻辑类-->
    <bean id = "bizObject" class="com.XXXX.XXX.XXXX.XXXX.service.demo.DemoServiceImpl"/>


    <!-- 增加调度业务 -->
    <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="bizObject" />
    <property name="targetMethod" value="saveDemo" />
    </bean>

    <!--执行调度-->
    <bean id = "ceshiTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="jobDetail"/>
    <property name="cronExpression" value="10 0/1 * * * ?"/>
    </bean>

    <!-- 启动调度 -->
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
    <list>
    <ref bean="ceshiTrigger" />
    </list>
    </property>
    <property name="taskExecutor" ref="executor" />
    </bean>

    </beans>
  • 相关阅读:
    PHP加速器eAccelerator安装
    WCF
    WCF
    WCF
    前端学习书籍推荐
    问题集录01--java对list列表进行排序
    基础知识:字符编码
    基础知识:if条件、while循环、for循环 相关练习
    基础知识:语言、编程、计算机组成、cpu、存储器
    视图 索引 存储过程
  • 原文地址:https://www.cnblogs.com/liuruilongdn/p/7793586.html
Copyright © 2011-2022 走看看