关闭

Spring 4.X整合Quartz2.X配置

2010人阅读 评论(0) 收藏 举报
分类:

spring-quartz.xml如下:

<?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">
	
	<bean id="job" class="com.cpwl.imifun.TestJob"></bean>
	
	<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject">
			<ref bean="job"/>
		</property>
		<property name="targetMethod">
			<value>test</value>
		</property>
	</bean>
	
	<bean id="trigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
		<property name="jobDetail">
			<ref bean="jobDetail"/>
		</property>
		<property name="cronExpression">
			<value>0/3 * * * * ?</value>
			<!-- 每3秒执行一次 -->
		</property>
	</bean>
	
	
	<bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref bean="trigger"/>
			</list>
		</property>
		<property name="autoStartup" value="true"></property>
	</bean>
	
</beans>


TestJob.java如下:

package com.cpwl.imifun;

import org.springframework.beans.factory.annotation.Autowired;

public class TestJob {
	
	@Autowired
	Dao dao;
	
	public void test(){
		System.out.println(dao.getAccountPageQuantity());
	}

}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:149822次
    • 积分:2527
    • 等级:
    • 排名:第14548名
    • 原创:100篇
    • 转载:0篇
    • 译文:0篇
    • 评论:31条
    文章分类
    最新评论