Spring Configuration Quartz Example _ timed task scheduling

Source: Internet
Author: User

1. Introduction of quartz jar Pack Quartz-all-1.8.6.jar except Spring.jar

2. Task class Quartzjob public class Quartzjob {public void Work1 () System.out.println ("Quartz Task Scheduling ... Work1 enable ... "); WORK2 () A System.out.println ("Quartz task schedule ...") Work2 enable ... "); 11} 12 13 14}

2.Spring configuration quartz-config.xml View Source printing? <?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:jee=" http:/ /www.springframework.org/schema/jee "    xsi:schemalocation=" http:// Www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd  05 Http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd "> 06   Modified  !--thread executor configuration for task registration-->     <bean id= "Executor"         class= " Org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor ">          <property name= "Corepoolsize"  value= "ten"  />         &nbSp;<property name= "Maxpoolsize"  value= " />"          <property name= "queuecapacity"  value= " />"     </ bean>       <!--the work class to invoke-->     <bean id= " Quartzjob " class=" Quartzjob "></bean>           <!-- Scheduling business: Defining methods for calling objects and calling objects-->     <bean id= "Jobtask1"          class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >          <!--called class-->          <property name= "TargetObject"  ref= "Quartzjob"  />          <!--methods in the calling class-->         <property&nbsP;name= "Targetmethod"  value= "Work1"  />     </bean>            <bean id= "Jobtask2"          class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >          <!--called class-->         <property  name= "TargetObject"  ref= "Quartzjob"  />          <!--calling methods in a class-->         <property name= "TargetMethod"  value= "Work2"  />     </bean> Notoginseng            <!--define trigger time-->     <bean id= "doTime1"  class= " Org.springframework.scheduling.quartz.CronTriggerBean ">        &nbSp;<property name= "Jobdetail"  ref= "Jobtask1"  />          <!--cron expression--><!--perform an--> every 10 seconds         < Property name= "Cronexpression"  value= "0/3 * * * *?"  />     </bean>            <bean id= "DoTime2"  class= "Org.springframework.scheduling.quartz.CronTriggerBean" >          <property name= "Jobdetail"  ref= "Jobtask2"  /> 47         <property name= "Cronexpression"  value= "0/5 * * * *?"  />

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.