码迷,mamicode.com
首页 > 编程语言 > 详细

spring定时器(一)

时间:2016-06-05 16:59:06      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

1. spring的application.xml配置文件

技术分享
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
 3     xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
 4     xmlns:context="http://www.springframework.org/schema/context" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
 5     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
 6         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
 7         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
 8         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
 9         http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
10     
11     <!-- 定义定时器任务  -->
12     <bean id="×××DaemonJob"
13             class="org.springframework.scheduling.quartz.JobDetailBean">
14     <!-- 指定任务对应的类 -->
15         <property name="jobClass" value="com.×××.×××.×××Job" />
16         <!-- 往任务中注入bean  -->        
17         <property name="jobDataAsMap">
18             <map>
19                 <entry key="×××" value-ref="×××"/>
20             </map>
21         </property>    
22     </bean>
23     
24     <!-- 定义任务的触发器 -->
25     <bean id="×××JobTrigger" 
26             class="org.springframework.scheduling.quartz.SimpleTriggerBean">        
27         <property name="jobDetail" ref="×××Job" />
28     <!-- 重复执行间隔时间(毫秒) -->
29         <property name="repeatInterval" value="300000"/>
30     <!-- 服务启动后多久执行(毫秒) -->
31         <property name="startDelay" value="1000"/>
32     </bean>
33     
34     <!-- 需要被执行的触发器集合 -->
35     <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
36         <property name="triggers">
37             <list>
38                 <ref bean="×××JobTrigger"/>
39             </list>
40         </property>
41     </bean>    
42     
43 </beans>
View Code

 

spring定时器(一)

标签:

原文地址:http://www.cnblogs.com/Mr-kevin/p/5561041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!