1: first, make sure that a spring web project can run. The spring version is 3.1, and the usage of 3.0 is somewhat different.
The quartz version is 2.0.2.
Throughout to run in addition to spring essential package but also quartz-all-2.0.2.jar, slf4j-api-1.6.4.jar
Please note that CronTriggerBean is used on the Internet. I tested the error and CronTriggerFactoryBean is used here.
Org. springframework. scheduling. quartz. CronTriggerFactoryBean
2: Add the following configuration in applicationContext. xml
<! -- Scheduled task class start -->
<Bean id = "jobClass" class = "com. ws. quartz. TestQuartz"> </bean>
<Bean name = "initTask" class = "org. springframework. scheduling. quartz. MethodInvokingJobDetailFactoryBean">
<Property name = "targetObject">
<Ref bean = "jobClass"/>
</Property>
<Property name = "targetMethod">
<Value> jobDetail </value>
</Property>
</Bean>
<Bean id = "cronTrigger" class = "org. springframework. scheduling. quartz. CronTriggerFactoryBean">
<Property name = "jobDetail">
<Ref bean = "initTask"/>
</Property>
<Property name = "cronExpression" value = "10, 15, 20, 25, 30, 35, 40, 45, 50, 55 ****? "/>
</Bean>
<Bean id = "start" lazy-init = "false" autowire = "no"
Class = "org. springframework. scheduling. quartz. SchedulerFactoryBean">
<Property name = "triggers">
<List>
<Ref bean = "cronTrigger"/>
</List>
</Property>
</Bean>
<! -- Scheduled task class end -->
--------------------- A method in the class
Public class TestQuartz {
Public void jobDetail (){
System. out. println ("scheduled task ");
}
}
Ps: In this example, the jobDetail method is executed every five seconds, and "scheduled task" is continuously played on the console"
This article from the "unemployed Travel" blog, please be sure to keep this source http://2820354.blog.51cto.com/2810354/1302162