首页 > 代码库 > SpringQuartz临时笔记

SpringQuartz临时笔记

	<!-- 要调用的工作类 -->
	<bean id="QuartzController" class="org.dbzy.analyse.controller.QuartzController"></bean>
	<!-- 定义调用对象和调用对象的方法 -->
	<bean id="jobtask"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<!-- 调用的类 -->
		<property name="targetObject">
			<ref bean="QuartzController" />
		</property>
		<!-- 调用类中的方法 -->
		<property name="targetMethod">
			<value>autoWork</value>
		</property>
	</bean>
	<!-- 定义触发时间 -->
	<bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="jobtask" />
		</property>
		<property name="cronExpression">
			<value>0 0 11,15,19 * * ?</value>
		</property>
	</bean>

	<!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
	<bean id="startQuertz" lazy-init="false" autowire="no"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref bean="doTime" />
			</list>
		</property>
	</bean>

SpringQuartz临时笔记