1.在xml中交给spring管理的一些类
<bean id="cancelOrderJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="orderJob"/>
<property name="targetMethod" value="cancelOrder"/>
</bean>
<!-- 运行一秒后开始之行 一分钟执行一次 -->
<bean id="cancelOrderTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="cancelOrderJobDetail"/>
<property name="startDelay" value="1000"/>
<property name="repeatInterval" value="60000"/>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="cancelOrderJobDetail"/>
</list>
</property>
<property name="triggers">
<list>
<ref bean="cancelOrderTrigger"/>
</list>
</property>
</bean>
2.创建orderJob类用来写我们的业务逻辑
@Component("orderJob")
public class cancelOrderJob {
//To Do
}
3.这样定时任务就配置完毕