1 <beans xmlns="http://www.springframework.org/schema/beans" 2 xmlns:context="http://www.springframework.org/schema/context" 3 xmlns:p="http://www.springframework.org/schema/p" 4 xmlns:mvc="http://www.springframework.org/schema/mvc" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans 7 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 8 http://www.springframework.org/schema/context 9 http://www.springframework.org/schema/context/spring-context.xsd 10 http://www.springframework.org/schema/mvc 11 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 12 13 <!-- 要调用的工作类 --> 14 <bean id="jobclass" class="com.sh.test.dingshi"></bean> 15 16 <!-- 配置方法调用 --> 17 <bean id="conJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 18 <property name="targetObject" ref="jobclass"></property> 19 <property name="targetMethod" value="say"></property> 20 <!-- 是否允许同时运行 --> 21 <property name="concurrent" value="false"></property> 22 </bean> 23 24 <!-- 定时重复执行 --> 25 <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 26 <property name="jobDetail" ref="conJob"></property> 27 <property name="cronExpression" > 28 <value>0/5 * * ? * * </value><!-- 配置5秒执行一次 --> 29 </property> 30 </bean> 31 32 <!-- 定时任务配置,定时工厂,用于管理配置的所有定时器,保证其在单独的线程上运行 --> 33 <bean id="quartzfactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 34 <property name="triggers"> 35 <list> 36 <ref local="cronTrigger"/><!-- 注册开关,local为上面配置的--> 37 </list> 38 </property> 39 </bean> 40 41 </beans>
相关文章: