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