<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>
quartzJob.xml
<!-- 定义目标bean和bean中的方法 -->
<!-- =====================日常任务job========================== -->
<bean>
</bean>
<bean>
<property>
<ref bean="DailyTaskQtzJob"/>
</property>
<property> <!-- 要执行的方法名称 -->
<value>execute</value>
</property>
</bean>
<!-- ======================== 调度触发器 ======================== -->
<bean>
<property ref="DailyTaskQtzJobMethod"></property>
<!-- 每天下午16:30触发 -->
<property value="0 30 16 ? * *"></property>
</bean>
<!-- ======================== 调度工厂 ======================== -->
<bean>
<property>
<list>
<ref bean="DailyTaskCronTriggerBean"/>
</list>
</property>
</bean>
DailyTaskJob.Java
package com.test.quartz;
public class DailyTaskJob {
protected void execute() {
//执行任务
}
}
最后在web.xml中添加quartzJob.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/beans.xml
WEB-INF/quartz/quartzJob.xml
</param-value>
</context-param>
OK,这就配好啦,记录一下,防止以后忘了。
推荐阅读:
Spring集成Quartz定时任务框架介绍和Cron表达式详解
Spring的Quartz定时器同一时刻重复执行二次的问题解决