Java Code test Class
public class Testquartz {public void Test () {System.out.println ("*********************quartz Task Scheduler ******************* **");}}
Quartz configuration file
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "http://www.springframework.org/ Schema/beans " xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance " xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd " > <beans> <!-- Quartz task class --> <bean id= "TestQuartz" class= "Com.brainlong.testQuartz.TestQuartz"/> <!-- Defines the method that invokes the Quartz task class --> <bean id= "TestTask" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" > <!-- called classes --> <property name= "TargetObject" ref= "Testquartz"/> <!-- Methods in the calling class also the method that the task executes--> <property name= "Targetmethod" value= "test"/> </bean> <!-- Define trigger Time --> <bean id= "DoTime" class= " Org.springframework.scheduling.quartz.CronTriggerBean "> <property name= "Jobdetail" ref= "Testtask"/> <!-- cron expression 10 s once--> &nBsp; <property name= "Cronexpression" value= "*/10&NBSP;*&NBSP;*&NBSP;*&NBSP;*&NBSP;?" /> </bean> <!-- quartz Task Scheduling general management class if lazy-init= ' false ' then the container starts executing the scheduler --> <bean id= "Startquertz" lazy-init= "false" autowire= "no" class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" > <property name= "Triggers" > <list> <ref bean= "DoTime" /> </list > </property> </bean> </beans></beans>
Then load this configuration file!
Attached: cronexpression configuration instructions (from the network)
Cron expression on-line generator: http://www.hahuachou.com/cron/index.htm
special characters allowed for field allowed values
seconds 0-59,-*/
Sub-0-59,-*/
hours 0-23,-*/
Date 1-31,-*?/L W C
month 1-12 or JAN-DEC,-*/
Week 1-7 or Sun-sat,-*?/L C #
year (optional) leave blank, 1970-2099,-*/
meaning of an expression
"0 0 12 * *?" trigger 12 o'clock noon every day.
"0 15 10?" * * "trigger 10:15 every day"
"0 15 10 * *?" Daily 10:15 Trigger
"0 15 10 * *?" * "10:15 per day" trigger
"0 15 10 * *?" 2005 "2005-year daily 10:15 trigger
"0 * 14 * *?" triggers every 1 minutes from 2 o'clock in the afternoon to 2:59 daily
"0 0/5 14 * *?" triggers every 5 minutes from 2 o'clock in the afternoon to 2:55 daily
"0 0/5 14,18 * *?" triggers every 5 minutes from 2 o'clock in the afternoon to 2:55 daily and from 6 o'clock in the afternoon to 6:55
"0 0-5 14 * *?" triggers every 1 minutes from 2 o'clock in the afternoon to 2:05 daily
"0 10,44 14?" 3 WED "2:10 and 2:44 triggers in Wednesday of every March
"0 15 10?" * Mon-fri "Monday to Friday 10:15 trigger
"0 15 10 15 *?" 15th 10:15 per month
"0 L *?" 10:15 on the last day of the month
"0 15 10?" * 6L "Last month of Friday 10:15 trigger
"0 15 10?" * 6L 2002-2005 "2002 to 2005 the last of the monthly Friday 10:15 trigger
"0 15 10?" * 6#3 "Monthly third Friday 10:15 trigger
Springquartz Timer Task Scheduler