Java Timer Trigger Timer

Source: Internet
Author: User

Xml:

<!--Java Timer Timer -    <!--<bean id= "Shorturltask" class= "Com.spring.common.ShortUrlTask" > </bean> <bean id= "Schedulerep Orttask "class=" Org.springframework.scheduling.timer.ScheduledTimerTask "> <property name=" TimerTask "ref=" s Horturltask "/> <property name=" period "> <value>500</value> </property>      ; </bean> <bean class= "Org.springframework.scheduling.timer.TimerFactoryBean" > <property name = "Scheduledtimertasks" > <list> <ref bean= "Schedulereporttask"/> </li st> </property> </bean> -        <!--<bean id= "Schedulertask" class= "Org.springframework.scheduling.quartz.JobDetailBean" > <property nam E= "Jobclass" > <value>com.spring.common.QuatzTime</value> </property> </be an> <bean id= "Schedulertasktrigger" class= "Org.springframework.scheduling.quartz.CronTriggerBean" > &  Lt;property name= "Jobdetail" ref= "Schedulertask"/> <property name= "cronexpression" > <VALUE>0/10 * * * * *?</value> </property> </bean> -           <BeanID= "Jobdetail"class= "Org.springframework.scheduling.quartz.JobDetailFactoryBean">        <!--durability Indicates whether the task is still persisted to the database after completion, by default false -        < Propertyname= "Durability"value= "true" />          <!--Target class/wmuitp/src/test/springquartz.java -        < Propertyname= "Jobclass"value= "Com.spring.common.QuatzTime"></ Property>       </Bean>              <!--Another type of trigger is Corntrigger -     <BeanID= "Corntrigger"class= "Org.springframework.scheduling.quartz.CronTriggerFactoryBean">       < Propertyname= "Jobdetail"ref= "Jobdetail"/>       <!--each 10-second trigger -       < Propertyname= "Cronexpression"value= "0/10 * *?"/>    </Bean>         <!--defining the Core scheduler -    <BeanID= "Scheduler"class= "Org.springframework.scheduling.quartz.SchedulerFactoryBean">      < Propertyname= "Triggers">        <refBean= "Corntrigger"/>      </ Property>    </Bean>

In the Java class:

 Public classQuatztimeextendsquartzjobbean{@Overrideprotected voidExecuteinternal (Jobexecutioncontext arg0)throwsjobexecutionexception {System.out.println ("The time is now:" +nowtime ()); }     PublicString Nowtime () {SimpleDateFormat SF=NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); String Time= Sf.format (NewDate ()); returnTime ; }}

Java Timer Trigger Timer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.