spring-quartz.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
 4     xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
 5     xsi:schemaLocation="http://www.springframework.org/schema/beans
 6        http://www.springframework.org/schema/beans/spring-beans.xsd
 7        http://www.springframework.org/schema/aop
 8        http://www.springframework.org/schema/aop/spring-aop.xsd
 9        http://www.springframework.org/schema/context
10        http://www.springframework.org/schema/context/spring-context.xsd
11        http://www.springframework.org/schema/tx
12        http://www.springframework.org/schema/tx/spring-tx.xsd">
13     
14 
15 
16     <!--配置清空MAP的作业类  -->
17      <bean id="testQuartz"
18         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
19         <property name="targetObject">
20             <bean class="com.pda.quartz.JobTest" />
21         </property>
22         <property name="targetMethod" value="test" />
23     </bean>
24     
25     
26       <!-- targetObject:指定包含任务执行体的Bean实例。
27       targetMethod:指定将指定Bean实例的该方法包装成任务的执行体。 -->
28       
29       
30     <!-- 配置清空MAP的触发方式 -->
31     <bean id="testTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
32         <property name="jobDetail" ref="testQuartz" />
33         <property name="cronExpression" value="0 */1 * * * ?" />
34     </bean>
35     
36     <!-- 配置调度工厂  -->
37     <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false">
38         <property name="triggers">
39             <list>                
40                 <!-- 清空MAP调度 -->
41                 <ref bean="testTrigger"/>
42             </list>
43         </property>
44     </bean> 
45     
46     
47 </beans>

 

 1 package com.pda.quartz;
 2 
 3 
 4 public class JobTest {
 5     
 6     public void test() {
 7         
 8         System.out.println("hhhh");
 9         
10     }
11 
12 }

 

posted @ 2016-09-27 11:14  SpringMVCMaven  阅读(1795)  评论(0编辑  收藏  举报