你的位置:首页 > Java教程

[Java教程]spring定时器(一)


1. spring的application.

 1 <??> 2 <beans ="http://www.springframework.org/schema/beans" ="http://www.w3.org/2001/   3   ="http://www.springframework.org/schema/tx" ="http://www.springframework.org/schema/aop" 4   ="http://www.springframework.org/schema/context" ="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