1, implementation and cyclic scheduling similar
Public class quartzjob3{ publicvoid Test () { simpledateformat sdf=new SimpleDateFormat ("HH:mm:ss"); System.out.println ("Spring new Method-using timed trigger-called" +sdf.format (new Date ()));} }
2, spring configuration as follows (1) Injection scheduling class object (Inject 2 class objects, trigger in different ways)
class class= "action. QuartzJob3 "/>
(2) Injection task scheduling management class object
<!--Configure the task scheduling management class object--- Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean "> <property name=" TargetObject "ref=" QuartzJob2 "/> <property name=" Targetmethod "value=" test "/> </bean> class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" > <property Name= "TargetObject" ref= "quartzJob3"/> <property name= "Targetmethod" value= "test"/> </bean >
(3) Defining a trigger (two triggers show the difference)
<!--defining triggers-simple triggers-- class= "Org.springframework.scheduling.quartz.SimpleTriggerBean" > <property name= "Jobdetail" ref= "methodInvoking1"/> <property name= "Startdelay" value= "$"/> <property name= "Repeatinterval" value= "$"/> </bean> <!--define triggers-timed triggers -- Class= "Org.springframework.scheduling.quartz.CronTriggerBean" > <property name= "Jobdetail" ref= " MethodInvoking2 "/> <property name=" cronexpression "value=" 0 15 * * *? " /> </bean>
(4) Factory mode activation trigger
<!--start Task-- class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" > < Property name= "Triggers" > <list> <ref local= "Simpletrigger"/> <ref local= " Crontrigger "/> </list> </property> </bean>
3. Test class
<!--start Task-- class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean" > <property name= "triggers" > <list> <ref local= "Simpletrigger"/> <ref local= " Crontrigger "/> </list> </property> </bean>
4, the operation results can be seen in the 16:15 time triggered by the timing trigger
3, spring new way to realize timing scheduling