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>
  • 相关阅读:
    Redis和MySQL的结合方案
    Java-CyclicBarrier的简单样例
    第十话-模板方法模式
    Codeforces 19D Points 线段树+set
    操作系统: 二级文件夹文件系统的实现(c/c++语言)
    mongodb数据库的启动和停止
    XML,HTML,XHTML
    android之ViewStub的使用
    教你实现语音识别(基于科大讯飞)
    android通过代码判断手机是否root
  • 原文地址:https://www.cnblogs.com/liuruilongdn/p/7793586.html
Copyright © 2011-2022 走看看