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>
  • 相关阅读:
    day6 面向对象(2)
    day5 面向对象
    day4 函数重载
    sqlserver 存储过程 增加
    sqlserver 存储过程 修改
    sqlserver 存储过程 删除
    sqlserver 存储过程 查询
    上篇: php 微信公众号 基于Thinkphp3.2框架开发
    bzoj 2726: [SDOI2012]任务安排
    bzoj 4199 [NOI2015]寿司晚宴
  • 原文地址:https://www.cnblogs.com/liuruilongdn/p/7793586.html
Copyright © 2011-2022 走看看