Spring supports quartz on its own, and these two integrations often arise from problems with the package version. and different versions of the configuration are a bit different.
I'm using a spring4.15+quartz-2.2.0.jar.
First configuration file Applicationcontext.xml
<!--Start the configuration of the trigger - <Beanname= "Startquertz"Lazy-init= "false"Autowire= "No"class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean"> < Propertyname= "Triggers"> <List> <refBean= "Myjobtrigger" /> </List> </ Property> </Bean> <!--end of configuration of startup trigger - <!--configuration of the quartz-2.x - <BeanID= "Myjobtrigger"class= "Org.springframework.scheduling.quartz.CronTriggerFactoryBean"> < Propertyname= "Jobdetail"> <refBean= "Myjobdetail" /> </ Property> < Propertyname= "Cronexpression">
<!--specify cron expression: 27th 16:21 Seconds Minutes Hours dayofmonth month DayofWeek year--<value>0 21 16 27 *? *</value> </ Property> </Bean> <!--The job configuration starts - <BeanID= "Myjobdetail"class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> < Propertyname= "TargetObject"> <refBean= "Punchjob" /> </ Property> < Propertyname= "Targetmethod"> <value>Work</value> </ Property> </Bean> <!--end of Job configuration - <!--The Working Bean - <BeanID= "Punchjob"class= "schedule." Punchjob " />
The cronexpression in the configuration file is the set time between, and the crontab in Linux is similar.
The following is the scheduler
Packageschedule;Importorg.springframework.beans.factory.annotation.Autowired;Importdomain. Attend;Importservice. EmployeeService; Public classPunchjob {@AutowiredPrivateEmployeeService EmployeeService; Public voidWork () {Attend attend=Newattend (); Employeeservice.iscome (attend); } }
Spring+quartz instances