为什么80%的码农都做不了架构师?>>>
一、spring4定时器任务配置如下:
<bean id="jsapiTask" class="chan.ye.dai.wexin.JsapiTicketTimeTask" /><bean id="jobDetail"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><property name="targetObject" ref="jsapiTask" /><property name="targetMethod" value="getTicket" /><property name="concurrent" value="false" /></bean><bean id="simpleTrigger"class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"><property name="jobDetail" ref="jobDetail" /><property name="startDelay" value="1000" /><property name="repeatInterval" value="3600000" /></bean><bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"><property name="triggers"><list><ref bean="simpleTrigger" /></list></property></bean>
二、spring4之前的定时器任务配置如下:
<bean id="jsapiTask" class="chan.ye.dai.wexin.JsapiTicketTimeTask"></bean><bean id="timerTask"class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean"><property name="targetObject" ref="jsapiTask"></property>这是要执行的对象<property name="targetMethod" value="getTicket"></property>这是要执行的对象的方法</bean>执行的时间 <bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask"><property name="delay" value="1000"></property>这是在spring容器实例化后的1秒后执行<property name="period" value="3600000"></property>这是每隔1小时后执行 <property name="timerTask" ref="timerTask"></property>这是要对哪个任务进行再执行</bean>开启计划 <bean class="org.springframework.scheduling.timer.TimerFactoryBean"><property name="scheduledTimerTasks"><list><ref bean="scheduledTask" />这是要执行的任务的时间规划加载进来 </list></property></bean>