zoukankan      html  css  js  c++  java
  • spring 定时任务配置使用

    1,自定义类

    package com.jd.service.meeting.worker;

    public class MyWorker {
    public void running(){
    System.out.println("hello, world!");
    }
    }

    二 ,配置使用

     <?xml version="1.0" encoding="GBK"?> 

    <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"
    default-autowire="byName">

    <bean id="helloWorker" class="com.jd.service.meeting.worker.MyWorker"></bean>

    <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      <property name="triggers">
    <list>
        <bean class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="jobDetail">
        <bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
            <property name="concurrent">
          <value>false</value>
        </property>
      <property name="targetObject">
          <ref bean="helloWorker" />
      </property>
      <property name="targetMethod">
        <value>running</value>
      </property>
      </bean>
      </property>
      <property name="cronExpression">
        <value>0/10 * * * * ?</value>
      </property>
      </bean>
        </list>
      </property>
      </bean>
    </beans>

  • 相关阅读:
    Leetcode-Pascal's Triangle
    SRM 619
    请用漂亮欢呼-------Day38
    创建list方法总结
    [ZJOI2019]语言
    jekyll 在博客添加流程图
    jekyll 在博客添加流程图
    HttpRepl 互操作的 RESTful HTTP 服务调试命令行工具
    HttpRepl 互操作的 RESTful HTTP 服务调试命令行工具
    How to use code to exit the application in UWP
  • 原文地址:https://www.cnblogs.com/bella-life-blog/p/6606204.html
Copyright © 2011-2022 走看看