1、配置Job实体类:
<bean id="myJob" class="com.quartz.MyJob"></bean>
2、配置JobDetail:
<
bean
id="
jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<
property
name="targetObject" ref="
myJob" />
<
property
name="targetMethod" value="execute" />
</
bean
>
3、配置触发器trigger:
<bean id="cronTriggerFactoryBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!-- jobDetail -->
<property name="jobDetail" ref="jobDetail"></property>
<!-- cron表达式,执行时间 每5秒执行一次 -->
<property name="cronExpression" value="0/5 * * * * ?"></property>
</bean>
4、配置调度工厂:
<bean id="springJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTriggerFactoryBean"></ref>
</list>
</property>
</bean>