每天早上8:30
每天下午五点整
每天下午五点半
上面的几个时间点到的时候、就调用配置的方法。我不知道我的配置对不对各位给看看:
- XML code
<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!--定时执行配置 --> <bean id="visInfoQuartz" class="com.boxun.crm.util.mms.DBSmsVisitInfo" /> <!-- bean触发方法配置 --> <bean name="quartzBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- bean名字 --> <property name="targetObject" ref="visInfoQuartz" /> <!-- bean方法 --> <property name="targetMethod"> <value>SmsVisInfo_M</value> </property> <property name="concurrent"> <value>false</value> </property> </bean> <!-- bean触发时间配置 每天早上8:30 --> <bean id="quartzTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <!-- 触发bean配置 --> <property name="jobDetail"> <ref bean="quartzBean" /> </property> <!-- 触发时间配置 每天早上8:30 --> <property name="cronExpression"> <value>0 30 8 * * ?</value> </property> </bean> <!-- bean触发方法配置 --> <bean name="DateBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- bean名字 --> <property name="targetObject" ref="visInfoQuartz" /> <!-- bean方法 --> <property name="targetMethod"> <value>SmsVisInfo_A</value> </property> <property name="concurrent"> <value>false</value> </property> </bean> <!-- bean触发时间配置 每天下午5:00 --> <bean id="DateTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <!-- 触发bean配置 --> <property name="jobDetail"> <ref bean="DateBean" /> </property> <!-- 触发时间配置 每天下午5:00 --> <property name="cronExpression"> <value>0 0 17 * * ?</value> </property> </bean> <!-- bean触发方法配置 --> <bean name="DayBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- bean名字 --> <property name="targetObject" ref="visInfoQuartz" /> <!-- bean方法 --> <property name="targetMethod"> <value>SmsVisInfo_B</value> </property> <property name="concurrent"> <value>false</value> </property> </bean> <!-- bean触发时间配置 每天下午5:30 --> <bean id="DayTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <!-- 触发bean配置 --> <property name="jobDetail"> <ref bean="DayBean" /> </property> <!-- 触发时间配置 每天下午5:30 --> <property name="cronExpression"> <value>0 30 17 * * ?</value> </property> </bean> <!-- quartz触发器管理 --> <bean id="sfb" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <!-- 添加触发器 --> <property name="triggers"> <list> <ref local="quartzTrigger" /> <ref local="DateTrigger" /> <ref local="DayTrigger"></ref> <!--这里调用的列表,还可以添加其他的任务--> </list> </property> </bean></beans>