一,pom.xml依赖的引入
<dependency>二,bean文件的配置
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<!-- 配置job类 -->Java文件
<bean id="scheduler1" class="com.taotao.order.scheduler.Scheduler1" />
<!-- 配置jobdetail类 -->
<bean id="springQtzJobMethod"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="scheduler1" />
</property>
<property name="targetMethod">
<value>execute</value>
</property>
</bean>
<!--配置定时器任务的调度器 -->
<bean id="quartzTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<!--声明要运行的实体 -->
<property name="jobDetail" ref="springQtzJobMethod">
</property>
<!--设置运行时间 -->
<property name="cronExpression">
<value>0/5 * * * * ?</value>
</property>
</bean>
<!--配置调度工厂 -->
<bean id="SpringJobSchedulerFactoryBean"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<!--注册定时器实体 集合 -->
<property name="triggers">
<list>
<ref bean="quartzTrigger" />
</list>
</property>
</bean>
package com.taotao.order.scheduler;corn表达式在线生成器地址
/**
* 创建一个job类
*
* @author LiuShuai
*
*/
public class Scheduler1 {
public void execute() {
System.out.println("任务已将执行。。。。。");
System.out.println("任务执行完毕。。。。。");
}
}