首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

定时支配-Spring集成Quartz

2012-12-20 
定时调度-Spring集成Quartz? context-param??param-namecontextConfigLocation/param-name??param-

定时调度-Spring集成Quartz

? <context-param>??<param-name>contextConfigLocation</param-name>??<param-value> ????? /WEB-INF/applicationContext.xml??</param-value>?</context-param>

(4)配置spring文件

?

?

<?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="quartzForTest" /><!-- 定义调用对象和调用对象的方法 --><bean id="jobtask" >   <!-- 调用的类  -->   <property name="targetObject">     <ref bean="quartzForTest"/>   </property>   <!--  调用类中的方法 -->   <property name="targetMethod">      <value>work</value>   </property>    </bean>        <!-- 定义触发时间 -->    <bean id="doTime" />      </property>     <!-- Cron表达式0 0/15 * * * ? 每15分钟执行一次 ; 0 46 11 * * ? 11点46执行一次; 0 0 2 * * ?每天两点执行;-->      <property name="cronExpression">       <value>0/2 * * * * ?</value>      </property>    </bean>        <!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->    <bean id="startQuertz" lazy-init="false" autowire="no" name="code">public class QuartzForTest {public void work(){System.out.println("test");}}

?

?

?

(6)完成!

ps:年的每天上午10:15触发年至2005年的每月的最后一个星期五上午10:15触发?
"0 15 10 ? * 6#3"?每月的第三个星期五上午10:15触发?


pps:打完收工!

ppps:我上传了一个项目包,可以直接使用的,jar包也在里面。

再见!


?

?

1 楼 lkfnn 2011-06-24   好东西,讲的真明白。

热点排行