Spring Consolidation Quartz (online example + own configuration)

Source: Internet
Author: User
Tags xmlns

I'm using the MyEclipse6.0 Spring version is 2.0; Quartz version is 1.5.2;

Main steps:

New Web project:

First Import jar package: Quartz-1.5.2.jar,spring.jar (with these two is enough);

Then configure Web.xml:

<?xml version= "1.0" encoding= "UTF-8"?> <web-app version= "2.5" xmlns= "http://java.sun.com/xml/ns/"
Java ee "
	xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "
	xsi:schemalocation=" http://java.sun.com/ Xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">

	<servlet>
		< servlet-name>spring</servlet-name>
		<servlet-class>
			Org.springframework.web.context.ContextLoaderServlet
		</servlet-class>
		<load-on-startup>1 </load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>spring </servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>


	< welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>


Then configure the spring configuration file: Applicationcontext.xml

<?xml version= "1.0" encoding= "UTF-8"?> <beans "xmlns=" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans-2.0.xsd "> <bean id=" firstjob "class=" Com.mc.job.First "></bean> <!--define methods in target beans and beans--> <bean id=" Job class= "Org.springframework.s Cheduling.quartz.MethodInvokingJobDetailFactoryBean "> <property name=" targetobject "> <ref local=" Firstjob "/> </property> <property name=" Targetmethod "> <!--the name of the method to execute--> <value>co Unt</value> </property> </bean> <!--define the trigger time--> <bean id= "cron class=" Org.springframewo Rk.scheduling.quartz.CronTriggerBean "> <property name=" jobdetail "> <ref bean=" Job "/> </property&
		Gt <property name= "Cronexpression" > <value>0-59 * * * *?</value> </property> </bean> <!--management triggers--> <bean autowire= "No" class= "ORG.SPR" Ingframework.scheduling.quartz.SchedulerFactoryBean "> <property name=" triggers "> <list> <ref Lo Cal= "cron"/> </list> </property> </bean> </beans>

The last is the test class: First.java

Package com.mc.job;

public class-A-
	static long Count = 0;
	public void Count () {
		count++;
		System.out.print ("count1=" +count);
	}



A very simple configuration integration example complete ...
The entire demo source code package (contains the required jar package) can go to my resources to download: http://download.csdn.net/detail/jerry_bj/3618605

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.