与Spring3整合必须使用Quartz1.8.5及以下版本
需要导入包
slf4j-api-1.6.1.jar
<!-- 定时任务
<bean id="quartzJob" class="com.task.Task" />
<bean id="jobtask"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="quartzJob" />
</property>
<property name="targetMethod">
<value>work</value>
</property>
</bean>
<bean id="doTime"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="jobtask" />
</property>
<property name="cronExpression">
<value>0 30,30,30,30 9,11,14,17 ? * MON-FRI</value>
</property>
</bean>
<bean id="startQuertz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="doTime" />
</list>
</property>
</bean>
-->
public class Task {
public void work() {
System.out.println("Quartz的任务调度");
}
}