转自:https://blog.csdn.net/lzj0470/article/details/17786587
quartz版本号:2.1.7
错误:
1 Caused by: <a href="http://lib.csdn.net/base/17" class="replace_word" title="Java EE知识库" target="_blank" style="color:#df3434; font-weight:bold;">java</a>.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class 2 at java.lang.ClassLoader.defineClass1(Native Method) 3 at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) 4 at java.lang.ClassLoader.defineClass(ClassLoader.java:615) 5 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 6 at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2854) 7 at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) 8 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) 9 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) 10 at org.springframework.util.ClassUtils.forName(ClassUtils.java:260) 11 at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) 12 at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1290) 13 at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)
解决:
将CronTriggerBean修改为CronTriggerFactoryBean。如:
1 <bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> 2 <property name="jobDetail" ref="myjob"/> 3 <property name="cronExpression" value="0/2 * * * * ?"/> 4 </bean>
注意:
由于Quartz 2.x修改了部分API,所以需要修改一下Quartz的配置。大体来说很简单,如下:
1)升级Spring的jar包
2)升级Quartz的jar包
3)修改配置
- 将CronTriggerBean修改为CronTriggerFactoryBean
- 将JobDetailBean修改为JobDetailFactoryBean