【学习笔记】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:




	
	
		
			
				
			
		
	
	

	
	
	
	
		
			
		
		
			0/1 * * * * ?
		
	
	

	
	
		
			
		
		
			work
		
	
	

	
	


MyJob.java:

import java.util.Date;

public class MyJob {

	public void work() {
		System.out.println("date:" + new Date().toString());
	}
}

web.xml:



	
	
	
		contextConfigLocation
		/WEB-INF/classes/applicationContext.xml
	

	
		org.springframework.web.context.ContextLoaderListener
	
	

	
		index.jsp
	



你可能感兴趣的:(学习笔记)