Quartz with spring, you still need scheduler instances, Jobdetail instances, trigger instances, just created in Factorybean way.
There are corresponding Factorybean classes in the Spring-context-support-xxx.jar package, and scheduler instances correspond to Org.springframework.scheduling.quartz. Schedulerfactorybean. Jobdetail instances correspond to two Factorybean classes, Org.springframework.scheduling.quartz. Jobdetailfactorybean and Org.springframework.scheduling.quartz. Methodinvokingjobdetailfactorybean. trigger instances correspond to two Factorybean classes, Org.springframework.scheduling.quartz. Simpletriggerfactorybean and Org.springframework.scheduling.quartz. Crontriggerfactorybean, Simpletriggerfactorybean corresponds to the generation of Simpletrigger instances, The crontriggerfactorybean corresponds to the generated Crontrigger instance.
Jobdetail instances created with Methodinvokingjobdetailfactorybean are not serializable and are not suitable for persistence of task scheduling information, so if you want to persist task scheduling information, You can only use Jobdetailfactorybean to create jobdetail instances.
These spring configuration files correspond to the following contents:
<BeanID= "Printjobdetail"class= "Org.springframework.scheduling.quartz.JobDetailFactoryBean"> < Propertyname= "Jobclass"value= "Com.kou.quartz.QuartzPrint"/> < Propertyname= "Durability"value= "false"/></Bean><BeanID= "Printcrontrigger"class= "Org.springframework.scheduling.quartz.CronTriggerFactoryBean"> < Propertyname= "Jobdetail"ref= "Printjobdetail"/> < Propertyname= "Cronexpression"value= "0/5 * * * * * *"/> <!--triggered once every 5 seconds -</Bean><BeanID= "Scheduler"class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean"> <!--specifying the quartz configuration file - < Propertyname= "Configlocation"value= "Classpath:quartz.properties"/> <!--quartzscheduler delay start, Quartzscheduler Restart after application start, unit seconds - < Propertyname= "Startupdelay"value= "1"/> <!--set up auto-start - < Propertyname= "Autostartup"value= "true"/> < Propertyname= "Triggers"> <List> <refBean= "Printcrontrigger"/> </List> </ Property> < Propertyname= "Overwriteexistingjobs"value= "true"/> <!--<property name= "DataSource" ref= "DataSource"/> -</Bean>
The Jobclass attribute value of Jobdetailfactorybean is the task class that we develop ourselves, You need to inherit the Org.quartz.Job interface or inherit the Org.springframework.scheduling.quartz.QuartzJobBean.
The Configlocation attribute value of Schedulerfactorybean is the Quartz.properties profile described in the previous article Quartz, which is placed under classpath.
The Overwriteexistingjobs property of Schedulerfactorybean defaults to false, and when trigger is executed every 5 seconds to execute once every 30 seconds, the task schedule is not changed until it is set to true.
Schedulerfactorybean's DataSource property cannot be set, if set, The class that is used to persist task scheduling information becomes a org.springframework.scheduling.quartz.localdatasourcejobstore,quartz.properties file org.quartz.jobStore.cl The "No" configuration item no longer works.
Quartz use (Integrated spring)