小虎j2ee历程

小虎的小小收集

常用链接

统计

最新评论

spring定时器

1.要下载一个quarz.jar包
2.配置文件

<?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:aop="http://www.springframework.org/schema/aop"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
  
  <bean id="testQuarz" class="com.san.report.RepostQuarz"/>
      
 
  <bean id="quartzDetail"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
   <property name="targetObject">
    <ref bean="testQuarz"/>
   </property>
    <property name="targetMethod">
    <value>Quarzprint</value>
   </property>
 </bean>

   <bean id="quartzDetail1"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
   <property name="targetObject">
    <ref bean="testQuarz"/>
   </property>
    <property name="targetMethod">
    <value>Quarzprint1</value>
   </property>
 </bean>
    <bean id="quartzDetail2"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
   <property name="targetObject">
    <ref bean="testQuarz"/>
   </property>
    <property name="targetMethod">
    <value>Quarzprint2</value>
   </property>
 </bean>
 
  <bean id="quartzTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
   <property name="jobDetail">
    <ref bean="quartzDetail"/>
   </property>
    <property name="cronExpression">
      <value>0 * 17 * * ?</value>
   </property>
 </bean>

  <bean id="quartzTrigger1" class="org.springframework.scheduling.quartz.CronTriggerBean">
   <property name="jobDetail">
    <ref bean="quartzDetail1"/>
   </property>
    <property name="cronExpression">
      <value>0 05 17 17 * ?</value>
   </property>
 </bean>

  <bean id="quartzTrigger2" class="org.springframework.scheduling.quartz.CronTriggerBean">
   <property name="jobDetail">
    <ref bean="quartzDetail2"/>
   </property>
    <property name="cronExpression">
      <value>0 01 17 ? * MON</value>
   </property>
 </bean>
 
  <bean  id="scheduler"  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      <property name="triggers">
      <list>
        <ref local="quartzTrigger"/>
  <ref local="quartzTrigger1"/>
  <ref local="quartzTrigger2"/>
      </list>
     </property>
  </bean>
</beans>

posted on 2007-12-18 17:50 小虎虎 阅读(281) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: