关于spring4+quartz2执行定时任务的问题

之前用的是spring3.0.5+quartz-1.6.5,以下是spring的xml代码:

  <!--周期数据定时入库-->

<bean id="allDataStorage"    class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >

<property name="targetObject" ref="iRawDataStorageService"/>

 <property name="targetMethod" value="allDataStorage" />

</bean>

 

<!--周期数据入库触发器 -->

<bean id="aDSTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">

<property name="jobDetail" ref="allDataStorage"/>

<property name="cronExpression" value="0 0/10 * * * ?"></property>

</bean>

 

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">

<property name="triggers">

<list>

<ref bean="aDSTrigger" />

</list>

</property>

</bean>

 

然而新的框架用的是spring4.2.2+ quartz2.2.2,我把之前定时任务的代码拷贝了过来,发现以下问题

 

Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)

at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)

at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:394)

at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1396)

at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1343)

... 62 more

 

上面提示的没有找到CronTriggerBean这个类,查了相关资料发现quartz2.0以上都需要将触发器中的CronTriggerBean改为CronTriggerFactoryBean 即:

 

<!--周期数据入库触发器 -->

<bean id="aDSTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean ">

<property name="jobDetail" ref="allDataStorage"/>

<property name="cronExpression" value="0 0/10 * * * ?"></property>

</bean>

你可能感兴趣的:(关于spring4+quartz2执行定时任务的问题)