/***************************************spring Configuration Code ***************************************/
<!--trigger Builder class, which generates the trigger object for the specified rule with the scheduler specified--
<bean id= "testtrigger" class= "org.springframework.scheduling.quartz.CronTriggerBean" >
<!--the action to be done after the trigger, this operation is managed by spring, only needs to specify a methodinvokingjobdetailfactorybean--
<property name= "jobdetail" ref= "testjobdetail"/>
<!--trigger rule, where the trigger rule is triggered once every 2 seconds-
<property name= "cronexpression" value= "*/2 * * * *?"/><!---->
</bean>
<!--task builder, which is managed by spring, only needs to specify its corresponding objects and methods, and the execution of the task is an object that calls a method--
<bean id= "testjobdetail"
class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<!--specifies the calling object for this task, which class does not need to implement any interfaces--
<property name= "targetObject" ref= "testjob"/>
<!--specify one of the methods in the TargetObject object--
<property name= "targetmethod" value= "execute"/>
<!--whether the task is allowed to execute concurrently. When the value is false, it means that you must wait until the previous thread has finished processing before starting a new thread--
<property name= "concurrent" value= "false"/>
</bean>
<!--a Common class for testing--
<bean id= "testjob" class= "com.wisdom.test.SMSTest.TestJob"/>
/**************************************** the code for the entity class ***************************************/
Package com.wisdom.test.SMSTest;
Import java.util.Date;
public class Testjob {
private static int count = 0;
public void Execute () {
try {
Thread.Sleep (3000);
System.out.println (new Date () + "--task i" + ++count + "times triggered");
} catch (Exception Ex) {
Ex.printstacktrace ();
}
}
}
/******************************* Time Rule *************************************************/
Execute once every 5 seconds: */5 * * * *?
Executes every 1 minutes: 0 */1 * * *?
Executed at 23 o ' day: 0 0 23 * *?
Once daily 1 o'clock in the morning: 0 0 1 * *?
Every month, 1th, 1 o'clock in the morning, once: 0 0 1 1 *?
The last day of the month is executed at 23 points: 0 0 L *?
Once a week, Sunday 1 o'clock in the morning: 0 0 1? * L
At 26, 29, 33, Execute once: 0 26,29,33 * * *?
Every day 0, 13, 18, 21 points are executed once: 0 0 0,13,18,21 * *?
Testing for Java triggers