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>
  • 相关阅读:
    大小端判断
    引用计数
    STL_ALGORITHM_H
    书单一览
    GIT版本控制系统(二)
    JS随机数生成算法
    STL学习笔记--临时对象的产生与运用
    乱序优化与GCC的bug
    你的灯亮着吗?
    交换机和路由器
  • 原文地址:https://www.cnblogs.com/liuruilongdn/p/7793586.html
Copyright © 2011-2022 走看看