Quartz结合PRING多任务定时调用.docVIP

  • 1
  • 0
  • 约 5页
  • 2016-11-22 发布于贵州
  • 举报
Quartz结合PRING多任务定时调用

Quartz结合SPRING多任务定时调用 定义两个被调度的类 public class QuartzJob { public void work() { System.out.println(Spring Quartz的任务调度1被调用!); //定时调用的业务逻辑 } } public class QuartzJob2 { public void work() { System.out.println(Spring Quartz的任务调度2被调用!); //定时调用的业务逻辑 } } Spring的配置文件 ?xml version=1.0 encoding=UTF-8? !-- - Application context definition for JPetStores business layer. - Contains bean references to the transaction manager and to the DAOs in - dataAccessContext-local/jta.xml (see web.xmls contextConfigLocation). -- beans xmlns=/schema/beans xmlns:xsi=/2001/XMLSchema-instance xmlns:aop=/schema/aop xmlns:tx=/schema/tx xsi:schemaLocation=/schema/beans /schema/beans/spring-beans-2.0.xsd /schema/aop /schema/aop/spring-aop-2.0.xsd /schema/tx /schema/tx/spring-tx-2.0.xsd !-- 要调用的工作类 -- bean id=quartzJob class=com.writchie.quartz.QuartzJob/bean bean id=quartzJobTwo class=com.writchie.quartz.QuartzJobTwo/bean !-- 可继续加新的任务 -- !-- 要调用的工作类结束 -- !-- 定义调用对象和调用对象的方法 -- bean id=jobtask class=org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean !-- 调用的类 -- property name=targetObject ref bean=quartzJob/ /property !-- 调用类中的方法 -- property name=targetMethod valuework/value /property /bean bean id=jobtask2 class=org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean !-- 调用的类 -- property name=targetObject ref bean=quartzJobTwo/ /property !-- 调用类中的方法 -- property name=targetMethod valuework/value /property /bean !-- 可继续加新的 -- !-- 定义调用对象和调用对象的方法结束 -- !-- 定义

文档评论(0)

1亿VIP精品文档

相关文档