Spring+quartz instances

Source: Internet
Author: User
Tags set time

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.