spring5.1.5+quartz2.3.1配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
   xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
   http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd
   http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd"
   default-lazy-init="false">
   	<!-- 定义任务的bean -->
	<bean id="synSectionInfoJob" class="com.zit.itmp.adapter.dms.webservice.SynSectionInfoJob" />
	<!-- 指定bean的方法 -->
	<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" autowire="no">
		<property name="targetObject" ref="synSectionInfoJob"/>
		<property name="targetMethod" value="work"/>
		<property name="concurrent" value="true"/>
	</bean>
	
	<!-- 启动时执行一次 -->
	<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
		<property name="jobDetail" ref="jobDetail"/>
		<!-- 延迟3秒执行 -->
		<property name="startDelay" value="3"/>
		<!-- 执行周期5秒-repeatCount为0时不生效 -->
		<property name="repeatInterval" value="5000"/>
		<!-- 执行1次 -->
		<property name="repeatCount" value="0"/>
	</bean>
	
	<!-- 按照指定规则定时执行 -->
	<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">  
		<property name="jobDetail">
			<ref bean="jobDetail" />
		</property>
		<!-- 每天凌晨3点执行一次 -->
		<property name="cronExpression">
			<value>0 0 3 * * ?</value>
		</property>
	</bean>
	
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
	  <property name="triggers">
	    <list>
	      <ref bean="simpleTrigger"/>
	      <ref bean="cronTrigger"/>
	    </list>
	  </property>
	</bean>
</beans>

猜你喜欢

转载自blog.csdn.net/taotao_guiwang/article/details/90050209