Version one:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd " > <!-- quartz configuration-1 register custom job class --> < bean name ="myJob" class ="com.test.quartz.helloworld.MyJob" ></ bean > <!-- quartz配置-2 配置JobDetail --> <bean name="myJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- 注入目标对象 --> <property name="targetObject" ref="myJob"></property> <!-- 注入目标方法 --> <property name="targetMethod" value="run"></property> </bean> <!-- quartz configuration-3 configuration trigger Trigger --> < bean name ="myTrigger" class ="org.springframework.scheduling.quartz.CronTriggerFactoryBean" > <!-- Injection task details object --> < property name ="jobDetail" ref ="myJobDetail" ></ property > <!-- Inject a cron expression, which specifies the trigger time --> < property name ="cronExpression" > <!-- every five seconds Clock trigger once --> < value > 0/5 * * * * ? </value> </property> </bean> <!--quartz配置-4 配置scheduler调度工厂--> <bean name="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <!-- 注入触发器 --> <property name="triggers"> <list> <ref bean="myTrigger"/> </list> </property> </bean> </beans>