Springquartz Timer Java

Source: Internet
Author: User

The first step:

Create a job class yourself

Package cn.msosm.msshopplatform.scheduler;/** * * @ClassName: Scheduler Create a Job Class * * @Description: the timer to check the order form according to the configuration time Have assigned data to assign red points to white points and get the amount * * @author SUNP * * @date September 15, 2017 PM 4:27:23 * */public class Scheduler {public void execute () { System.out.println ("task begins execution ....") "); System.out.println ("..."); SYSTEM.OUT.PRINTLN ("Task execution complete ....") ");}}


Step Two

Configuring the Task Scheduler in the spring configuration file

<!--  Configure job Class    Task Scheduler  --><bean id= "Scheduler"  class= " Cn.msosm.msShopPlatform.service.scheduler.Scheduler "/><!--   configuration Jobdetail --><bean  id= "Springqtzjobmethod"  class= " Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean "><property name=" TargetObject "><ref bean=" Scheduler "/></property><property name=" Targetmethod "> <!--  Name of the method to execute  --><value>execute</value></property></bean><!--  Configuration   Trigger  trigger --><bean id= "Crontriggerfactorybean"  class= " Org.springframework.scheduling.quartz.CronTriggerFactoryBean "><property name=" Jobdetail " ref=" Springqtzjobmethod "></property><property name=" cronexpression " value=" 0/5 * *  * * ? " ></property><!--  Execution time    seconds   minutes     days   weeks    --><!- -&nbsp Cron expression 1 .  Seconds 2 .  Minutes 3 .  Hours 4 .  Day-of-Month 5 .  Month 6 .  Day-of-Week 7 .  year (optional field)  --></bean><!--  Configure dispatch factory  --><bean id= "Schedulerfactorybean " class=" Org.springframework.scheduling.quartz.SchedulerFactoryBean "><property name=" triggers " ><list><ref bean= "Crontriggerfactorybean"/></list></property></bean>


Step Three:

Tomcat Deployment Run





Springquartz Timer Java

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.