spring定时任务quartz使用xml配置文件

1. 实现写一个*.xml文件,该文件在spring初始文件中引入该文件。例如在application.xml中引入该文件。(先导入相应的jar包)    <import resource="spring/applicationContext-quartz.xml" />


2. 然后在在定时任务文件中配置3个步骤:

<bean id="InsuranceAssociationTask" 
class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass">
<value>quartzImpl.QuzerTime</value>
</property>
</bean>
 
<bean id="InsuranceAssociationTimerTask"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="InsuranceAssociationTask" />
<property name="cronExpression" value="0 0/50 * * * ?" />
</bean>
 
<bean id="SchedulerFactoryTest"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="InsuranceAssociationTimerTask" />
</list>
</property>
<!-- 目前不做配置,暂时用不着 -->
<!-- property name="configLocation" value="classpath:config/quartz.properties" /  -->
</bean>

3.然后配置实现类即可。




猜你喜欢

转载自blog.csdn.net/dhq_blog/article/details/80390810