Spring-3.2.4 + Quartz-2.2.0集成实例
Spring3.0不支持Quartz2.0,因为org.quartz.CronTrigger在2.0从class变成了一个interface造成IncompatibleClassChangeError错误:
Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class
今天刚下载了Spring3.2.4,发现这个新版本已经支持quartz2.x了.以前的Spring版本只支持Quartz-1.8.x及以前的版本,做个小实例分享一下.
注:Spring3.2.4配置文件中使用CronTriggerFactoryBean来集成quartz2.x,使用CronTriggerBean来集成quartz1.8.x及以前版本.
代码结构及引用jar见下图:
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><!-- Spring config start --><context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/classes/applicationContext.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- Spring config end --><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>
代码下载地址: http://pan.baidu.com/share/link?shareid=731523671&uk=654552105