springMVC Framework Configuration Timers

Add the following in springmvc.xml
added in the xmlns

xmlns: Task = "http://www.springframework.org/schema/task"
. 1
added in xsi

http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.2.xsd

xmlns: task = "http://www.springframework.org/schema/task"

added intermediate

<-! - set the timing task>
: <Annotation-Driven / Task>

under TimerTask new class that needs to be placed springMVC annotation framework.
code show as below:

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/ **
*
* Class Name: TimerTask
* Class Description: Timer task
*
* /
@Component
public class TimerTask {
/ **
* Start the task every day 22:30
* /
@Scheduled (cron = "0 30 22 * *?" )
public void test1 ()
{
System.out.println ( "the jobs that job1 begin ..." + TimeUtils.getTime ());
}
@Scheduled (= the cron "? * * * * 0/5") // every 5 seconds interlaced once
public void test2 ()
{
System.out.println ( "JOB2 started");
}
}

About the cron configuration

CRON expression meaning
"0012 * *?" Every day noon trigger
"01510? * *" 10:15 every morning trigger
"01510 * *?" 10:15 every morning trigger
"01510 * * *? "10:15 every morning trigger
" 01510 * *? 2005 "2005 10:15 every morning trigger
" 0 * 14 * *? "every day from 14:00 to 2:59 start every minute a trigger
"0 0/5 14 * *?" from 14:00 to 2:55 o'clock the day began to trigger once every 5 minutes
"0 0/5 * 14, 18 *?" the daily 14:00 to 2:55 and 6:00 to 6:55 time period of two trigger every 5 minutes
"00-514 * *?" 14:00 to 14:05 minutes per day once triggered
"0 10,44 14? 3 WED" March every Wednesday of 14:10 and 14:44 triggering
"0 15 10? * MON- FRI" every Monday, Tuesday, Wednesday, Thursday, Friday triggered 10:15

Guess you like

Origin www.cnblogs.com/xianz666/p/12005569.html
Recommended