<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byType">
<!-- ======================== 任务 Task配置 ======================== -->
<bean id="importLmTable" class="com.opensource.prt.lm.quartz.LmQueryControlQuartzService"></bean>
<!--由MethodInvokingJobDetailFactoryBean实现 -->
<bean id="importLmJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="importLmTable" />
<property name="targetMethod" value="run" />
<property name="concurrent" value="false" />
<property name="arguments">
<list></list>
</property>
</bean>
<!-- ======================== 配置定时调度 触发器 ======================== -->
<!--由CronTriggerFactoryBean实现 -->
<bean id="cronTrigger"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="importLmJob" />
<property name="cronExpression" value="0 0 */1 * * ?" />
</bean>
<!-- ======================== 调度工厂(中心调度器) ======================== -->
<bean id="schedulerFactoryBean"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
autowire="no">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
</beans>
调用定时
public class LmQueryControlQuartzService implements Runnable {
@Override
public void run() {
//代码
}
}
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.4</version>
</dependency>