先看applicationContext.xml下面的beans
-
- <!-- Trigger -->
-
- <bean id="autoJob" class="com.spring.app.AutoJob" />
-
- <bean id="autoTask" class="com.spring.app.AutoTask" />
-
- <bean name="autoWeekly" class="org.springframework.scheduling.quartz.JobDetailBean">
- <property name="jobClass" value="com.spring.app.AutoWeekly" />
- </bean>
-
- <bean id="job" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
-
- <property name="jobDetail" ref="jobDetail" />
- <property name="startDelay" value="10000" />
- <property name="repeatInterval" value="50000" />
- </bean>
-
- <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
- <property name="jobDetail" ref="autoWeekly" />
- <!-- run every morning at 6 AM -->
- <property name="cronExpression" value="0 33 18 * * ?" />
- </bean>
-
- <bean id="scheduledTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
- <!-- wait 10 seconds before starting repeated execution -->
- <property name="delay" value="1000" />
- <!-- run every 50 seconds -->
- <property name="period" value="5000" />
- <property name="timerTask" ref="autoTask" />
- </bean>
- <!-- 使用TimerFactoryBean來設置任務 -->
- <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
- <property name="scheduledTimerTasks">
- <list>
- <ref bean="scheduledTask" />
- </list>
- </property>
- </bean>
-
- <bean id="jobDetail"
- class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <property name="targetObject" ref="autoJob" />
- <property name="targetMethod" value="doIt" />
- <property name="concurrent" value="false" />
- </bean>
-
- <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="cronTrigger" />
- <ref bean="job" />
- </list>
- </property>
- </bean>
-
- <!-- Trigger end -->