使用Spring配置管理Quartz的时候会遇到下面的异常:java
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class
缘由是Spring 3.2版本中内置的Quartz版本与Quartz包2.2中的接口不兼容。spring
解决办法:CronTriggerBean 替换成 CronTriggerFactoryBean。并发
配置以下:app
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> ide
<property name="triggers"> spa
<list> 线程
<ref bean="billTrigger"/> 接口
</list> get
</property> it
<property name="autoStartup" value="true"/>
</bean>
<bean id="billTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="billJobDetail"/>
<property name="cronExpression" value="59/1 * * * * ?"/>
</bean>
<!-- 每隔1秒钟触发一次 -->
<bean id="billJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="billJob"/>
<property name="targetMethod" value="execute"/>
<property name="concurrent" value="false"/>
</bean> <!-- 是否容许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
<bean id="billJob" class="cn.com.infinitus.moa.application.job.DownloadBillJob"/>