In addition to spring-related jar packages, you need to introduce Quartz-all-1.6.6.jar.
Spring config file adds quartz-bean.xml and Quartz-set.xml
Quartz-bean.xml:
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0 . xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP/SPRING-AOP -3.0.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-t X-3.0.xsd "> <!--Test - <BeanID= "Testquartztask"class= "Com.tech.jin.quartz.TestQuartzTask"/> </Beans>
Quartz-set.xml:
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0 . xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP/SPRING-AOP -3.0.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-t X-3.0.xsd "> <!--Scheduled Task Definition - <Beanclass= "Org.springframework.scheduling.quartz.SchedulerFactoryBean"> < Propertyname= "Quartzproperties"> <Props> <propKey= "Org.quartz.threadPool.threadCount">50</prop> </Props> </ Property> <!--Auto Start - < Propertyname= "Autostartup"> <value>True</value> </ Property> < Propertyname= "Triggers"> <List> <refLocal= "Testquartztasktrigger" ></ref><!--Test Automatic Tasks -<!--<ref local= "Transqueryjobtrigger"/> - </List> </ Property> </Bean> <!--Test Automatic Tasks - <BeanID= "Testquartztasktrigger"class= "Org.springframework.scheduling.quartz.CronTriggerBean"> < Propertyname= "Jobdetail"> <refBean= "Testquartztaskjobdetail"/> </ Property> < Propertyname= "Cronexpression"> <value>0/10 * * * *?</value> </ Property> < Propertyname= "Jobdataasmap"> <Map> <entryKey= "Jobclass"value= "Testquartztask"/> <entryKey= "JobName"value= "Test Automatic task"/> </Map> </ Property> </Bean> <BeanID= "Testquartztaskjobdetail"class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> < Propertyname= "TargetObject"><refBean= "Testquartztask"/></ Property> < Propertyname= "Targetmethod"><value>Dotask</value></ Property> < Propertyname= "Concurrent"value= "false"/> </Bean> </Beans>
The class called Testquartztask:
Package Com.tech.jin.quartz; Import Org.apache.log4j.Logger; Public class testquartztask { private Logger Logger = Logger.getlogger (testquartztask. Class); Public void Dotask () { logger.info ("66666666666666666666666");} }
In addition to this, the configuration for reading the sping configuration file needs to be added in Web. xml: Classpath:spring/quartz-*xml
< Context-param > < Param-name >contextconfiglocation</param-name> < Param-value> classpath:spring/applicationcontext.xml; Classpath:spring/quartz-*xml </param-value> </ context-param>
Sping Quartz set a scheduled task