SPRING3.0 does not support Quartz2.0 because Org.quartz.CronTrigger in 2.0 has changed from class to a interface to cause Incompatibleclasschangeerror errors:
caused By:java.lang.IncompatibleClassChangeError:class Org.springframework.scheduling.quartz.CronTriggerBean has Interface Org.quartz.CronTrigger as Super class
Today, I just downloaded Spring3.2.4 and found that this new version has already supported quartz2.x. Previous spring versions only support quartz-1.8.x and previous versions, and share them in small instances.
Note: Crontriggerfactorybean is used to integrate quartz2.x in the Spring3.2.4 configuration file, and Crontriggerbean is used to integrate quartz1.8.x and previous versions.
Code structure and reference jar see the following figure:
Applicationcontext.xml:
[html] View Plain Copy <?xml version= "1.0" encoding= "UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:xsi= "http:// Www.w3.org/2001/XMLSchema-instance " xmlns:p=" http://www.springframework.org/schema/p " xsi:schemalocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "> <!-- Startup trigger configuration start --> <bean name= "Startquertz" lazy-init= "false" autowire= "no" class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" > <property name= "triggers" > <list> <ref bean= "Myjobtrigger" /> </list> </property> </bean> <!-- Start trigger configuration end --> <!-- Scheduling configuration start --> <!-- quartz-1.8 Previous configuration <bean id= "Myjobtrigger" class= " Org.springframework.scheduling.quartz.CronTriggerBean "> <property name= "Jobdetail" >   <ref bean= "MyJobDetail" / > </property> <property name= "Cronexpression" > <value>0/1 * * * * ?</ value> </property> </bean> --> <!-- quartz-2.x configuration --> <bean id= "Myjobtrigger" class= " Org.springframework.scheduling.quartz.CronTriggerFactoryBean "> <property name= "Jobdetail" >&Nbsp; <ref bean= " Myjobdetail " /> </property> <property name= "Cronexpression" > <value>0/1 * * * * ?</value> </property> </bean> <!-- Dispatch configuration End --> <!-- job configuration start --> <bean id= "Myjobdetail" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" > &nBsp; <property name= "TargetObject" > <ref bean= "Myjob" /> </property> <property name= "Targetmethod" > <value>work</value> </property > </bean> <!-- job End of configuration --> <!-- work bean --> <bean id= "Myjob" class= "Com.tgb.lk.demo.quartz.MyJob" /> </beans>
Myjob.java:
[Java] View plain copy import java.util.Date; public class Myjob {public void work () {System.out.println ("date:" + new Date (). toString ()); } }
Xml:
[html] View Plain Copy <?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>
Code Download Address: http://download.csdn.net/detail/lk_blog/6277021