spring4+quartz2.2.3, scheduled tasks have been fixed, modify the timing task did not toss up, did not find the right solution.
Finally using the library Spring-context-support 3.2.17.RELEASE + quartz 1.8.0 to solve, quart1.8.x version of the Crontriggerbean get up handy
The key code is as follows:
1.maven file
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactid>quartz</ artifactid> <version>1.8. 0</version> </dependency> <dependency> <groupid>org.springframework </groupId> <artifactId>spring-context-support</artifactId> <version>3.2 . . Release</version> </dependency>
2.spring-quartz.xml file
<BeanID= "Scheduleinfoaction"class= "Com.aaa.controller.AutoTaskController"> < Propertyname= "Scheduler"ref= "Schedulerfactory"/> </Bean> <BeanID= "Schedulerjobdetail"class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> < Propertyname= "TargetObject"ref= "Scheduleinfoaction"/> < Propertyname= "Targetmethod"value= "Execute"/> < Propertyname= "Concurrent"value= "false"/> </Bean> <BeanID= "Packetresolvetrigger"class= "Org.springframework.scheduling.quartz.CronTriggerBean" > < Propertyname= "Jobdetail"ref= "Schedulerjobdetail"/> < Propertyname= "Cronexpression"> <value>0/5 * * * *?</value> </ Property> </Bean> <BeanID= "Schedulerfactory"class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean"> < Propertyname= "Triggers"> <List> <refLocal= "Packetresolvetrigger"/> </List> </ Property> </Bean>
3.java Code
Package Com.aaa.controller; @Api ("Timed task Interface") @Controller @requestmapping ("/task") Public class Autotaskcontroller {
Private Scheduler Scheduler;
public void Setscheduler (Scheduler Scheduler) {
This.scheduler = Scheduler;
}
//Timed task execution
protected voidExecute ()throwsException {System.out.println ("Timed task execution, parsing:" +NewDate ()); }
Modify Public voidChangecrontime (String ex)throwsexception{//Get Timer Try{Crontriggerbean Trigger= (Crontriggerbean) scheduler.gettrigger ("Packetresolvetrigger", Scheduler.default_group); System.out.println (Trigger.getcronexpression ()); Trigger.setcronexpression ("0/1 * * * *?"); Scheduler.reschedulejob ("Packetresolvetrigger", Scheduler.default_group, Trigger); } Catch(schedulerexception E1) {e1.printstacktrace (); } Catch(ParseException E1) {e1.printstacktrace (); } }}
Spring + Quartz timed tasks, and modify timed tasks