I use myeclipse6.0 spring 2.0 and quartz 1.5.2;
Main steps:
Create a web project:
First import jar package: quartz-1.5.2.jar, spring. Jar (these two are enough );
Then configure web. xml:
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"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>
Configure the spring configuration file applicationcontext. xml.
<? XML version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" 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 the target bean and bean --> <bean id = "job" class = "org. springframework. scheduling. quartz. methodinvokingjobdetailfactorybean "> <property name =" targetobject "> <ref local =" firstjob "/> </property> <property name =" targetmethod "> <! -- Name of the method to be executed --> <value> count </value> </property> </bean> <! -- Define the trigger time --> <bean id = "cron" class = "org. springframework. scheduling. quartz. crontriggerbean "> <property name =" jobdetail "> <ref bean =" job "/> </property> <property name =" cronexpression "> <value> 0-59 ** **? </Value> </property> </bean> <! -- Manage triggers --> <bean autowire = "no" class = "org. springframework. scheduling. quartz. schedulerfactorybean "> <property name =" triggers "> <list> <ref local =" cron "/> </List> </property> </bean> </beans>
The last is the test class: first. Java
package com.mc.job;public class First {static long Count = 0;public void Count() {Count++;System.out.print("Count1="+Count);}}
A simple example of configuration integration is completed...
The source code package of the entire demo (including the required jar package) can be downloaded to my resources: http://download.csdn.net/detail/jerry_bj/3618605