Use Spring to configure the scheduled service.

Source: Internet
Author: User

I found some information about spring scheduled execution tasks on the Internet, and found that all the information is detailed, but the jar package to be introduced is missing.

 

In this case, if the jar package in the project is not full, the configuration file will report an error, which will be quite troublesome for some new users (such as me.

 

The configuration of the scheduled service is as follows:

 

Add the following code to the spring configuration file.

 

<! -- Start customization service --> <br/> <bean id = "methodinvokingjobdetail" <br/> class = "org. springframework. scheduling. quartz. methodinvokingjobdetailfactorybean "> <br/> <property name =" targetobject "> <br/> <! -- Your own service to be associated --> <br/> <ref bean = "cardinfomanager"/> <br/> </property> <br/> <property name = "targetmethod "> <br/> <! -- The method outputlocaltime in the associated service is the name of the method to be executed --> <br/> <value> outputlocaltime </value> <br/> </property> <br/> </bean> </P> <p> <! -- Define the trigger time --> <br/> <bean id = "cront" class = "org. springframework. scheduling. quartz. crontriggerbean "> <br/> <property name =" jobdetail "> <br/> <ref bean =" methodinvokingjobdetail "/> <br/> </property> <br/> <! -- The value below is the set trigger time --> <br/> <property name = "cronexpression"> <br/> <value> 0/10 0 **? </Value> <br/> </property> <br/> </bean> </P> <p> <! -- Total management --> <br/> <Bean class = "org. springframework. scheduling. quartz. schedulerfactorybean "> <br/> <property name =" triggers "> <br/> <list> <ref local =" cront "/> </List> <br/> </property> <br/> </bean> <br/> <! -- End of Custom Service -->

 

Note that at this time the system needs to introduce the quartz-all-1.6.1.jar jar package or the spring configuration file will be out:

 

"No setter found for property 'cronexpression 'in class..." error.

 

At the same time to put the "commons-collections-3.2.jar" into the lower version or don't put it may have the following error:

 

"

Java. Lang. nosuchmethoderror: org. Apache. commons. Collections. setutils. orderedset (ljava/util/set;) ljava/util/set;

"

 

You just need to put the jar above under the Lib of the project.

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.