spring中配置quartz定时器

spring中配置quartz定时器

jar包说明

spring3.0+quartz1.0版本,这里如果使用quartz2.0的话,spring的jar包要3.2版本以上

spring中配置quartz定时器_第1张图片

下载地址:http://download.csdn.net/detail/dzy21/9582333

实体类的方法

定时器就来调用这个方法

package com.cloud.impl;

public class GetDataImpl {

   public void getData(){

      System.out.println("测试定时器的数据拉取...");

   }

}

spring配置文件

xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"

   xmlns:context="http://www.springframework.org/schema/context"

   xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"

   xsi:schemaLocation="

            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

            http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd

            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  

   <bean id="getDataImpl" class="com.cloud.impl.GetDataImpl">bean>

  

   <bean id="getDataQuart" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

     

      <property name="targetObject" ref="getDataImpl"/>

     

      <property name="targetMethod" value="getData"/>

     

      <property name="concurrent" value="false" />

   bean>

  

   <bean id="getDataTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">

      <property name="jobDetail" ref="getDataQuart"/>

     

      <property name="cronExpression">

         <value>0 0-59/1 0-23 * * ?value>

      property>

   bean>

  

   <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">

      <property name="triggers">

         <list>

           

            <ref bean="getDataTrigger"/>

         list>

      property>

   bean>

beans>

web.xml配置文件

xml version="1.0" encoding="UTF-8"?>

<web-app version="3.0"

   xmlns="http://java.sun.com/xml/ns/javaee"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

  <display-name>display-name>

 

  <welcome-file-list>

    <welcome-file>index.jspwelcome-file>

  welcome-file-list>

 

  <context-param>

  <param-name>contextConfigLocationparam-name>

  <param-value>classpath:applicationContext.xmlparam-value>

  context-param>

 

  <listener>

  <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>

  listener>

web-app>

 

你可能感兴趣的:(spring,quartz,jar,java,[---Spring---])