quartz重复问题
下面是我在网上下的配置文件,都会打印一段话,但不知道为什么结果不对
quartzJob:我设定的是30秒一次
quartzJob2: 1分钟执行一次
打印结果如下:
1111Thu Apr 11 09:32:30 CST 2013
******************
1111Thu Apr 11 09:33:00 CST 2013
******************
222222Thu Apr 11 09:33:00 CST 2013
==============
1111Thu Apr 11 09:33:30 CST 2013
******************
1111Thu Apr 11 09:34:00 CST 2013
******************
222222Thu Apr 11 09:34:00 CST 2013
==============
1111Thu Apr 11 09:34:30 CST 2013
******************
1111Thu Apr 11 09:35:00 CST 2013
******************
222222Thu Apr 11 09:35:00 CST 2013
==============
问题:为什么打印1以后 打印2的时候1也要打印一次?
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 要调用的工作类 -->
<bean id="quartzJob" class="cn.jq.com.utils.MyQuartz"></bean>
<bean id="quartzJob2" class="cn.jq.com.utils.MyQuartz2"></bean>
<!-- 定义调用对象和调用对象的方法 -->
<bean id="jobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="quartzJob"/>
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod">
<value>work</value>
</property>
</bean>
<!-- 定义触发时间 -->
<bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="jobtask"/>
</property>
<!-- cron表达式 -->
<property name="cronExpression">
<!-- 每隔10秒执行一次-->
<value>0/30 * * * * ?</value>
</property>
</bean>
<!-- 定义调用对象和调用对象的方法 -->
<bean id="jobtask2" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="quartzJob2"/>
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod">
<value>work</value>
</property>
</bean>
<!-- 定义触发时间 -->
<bean id="doTime2" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="jobtask2"/>
</property>
<!-- cron表达式 -->
<property name="cronExpression">
<!-- 每隔10秒执行一次-->
<value>0/60 * * * * ?</value>
</property>
</bean>
<!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="doTime"/>
<ref bean="doTime2"/>
</list>
</property>
</bean>
</beans>
[解决办法]
0/30 * * * * ?//每30秒执行一次
0/60 * * * * ?//每一分钟执行一次,当然包含30秒了。