The recent project to use the task scheduling related knowledge, yesterday confidence full to the official website to study, the result was pit a half-dead, I use the latest version of Quartz, the document is said to be compatible with all versions, but the code even compile all the error, helpless had to find information from the internet, Stones finally a little prospect, in this share, by the way Maven Project: Pom.xml references are as follows: org.quartz-scheduler quartz 2.1.7 org.quartz-scheduler quartz-oracle 2.1.7 org.quartz-scheduler quartz-weblogic 2.1.7 org.quartz-scheduler quartz-jboss 2.1.7 The relevant classes are as follows: Package Test.quartz;import Java.util.date;import Org.quartz.job;import org.quartz.jobexecutioncontext;import Org.quartz.jobexecutionexception;public class Simplejob implements job {//① Instance job interface method public void execute ( Jobexecutioncontext context) throws Jobexecutionexception {//Say Hello to the world and display the Date/time System.out . println ("Hello world! -"+ new Date ());}} Package Test.quartz;import Org.quartz.jobbuilder;import Org.quartz.jobdetail;import org.quartz.scheduler;import Org.quartz.schedulerfactory;import Org.quartz.simpleschedulebuilder;import Org.quartz.trigger;import Org.quartz.triggerbuilder;public class Simpletriggerrunner {public static void main (string[] args) throws Exception {Sch Edulerfactory schedfact = new Org.quartz.impl.StdSchedulerFactory (); Scheduler sched = Schedfact.getscheduler (); Define the job and tie it to our Hellojob class Jobdetail job = Jobbuilder.newjob (Simplejob.class). Withidentity ("MyJob" , "Group1"). Build (); Trigger the job to Run now, and then every seconds Trigger Trigger = Triggerbuilder.newtrigger (). Withidentity ("Mytrigger", "Group1"). Star Tnow (). Withschedule (Simpleschedulebuilder.simpleschedule (). Withintervalinseconds (2). RepeatForever ()). build (); Tell Quartz to schedule the job using our trigger sched.schedulejob (job, trigger); Sched.start (); Thread.Sleep (9L * 1000L); Sched.shutdown (TRUE); The demo above is the simplest example of getting started, and more complex instructions are required to refer to the documentation.
Java Task Scheduler