spring mvc 定时任务 为什么每次都是3次同时执行
不论cron怎么配置,它都是每次同时运行3次这个doCollect方法。设置成“0*17**?”也是每分钟同时跑3次。不应该是每次只跑一次么。配置文件:<beanname...
不论cron怎么配置,它都是每次同时运行3次这个doCollect方法。设置成“0 * 17 * * ?”也是每分钟同时跑3次。不应该是每次只跑一次么。
配置文件:
<bean name="visitLogCollectService" class="xx.service.VisitLogCollectService" />
<bean id="jobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="visitLogCollectService" />
<property name="targetMethod" value="doCollect" />
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDetail" />
<property name="cronExpression" value="0 30 17 * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
<property name="taskExecutor" ref="executor" />
</bean>
方法:
@Service("visitLogCollectService")
public class VisitLogCollectService {
public void doCollect(){
System.out.println("sssssssssssssssssssssssssssssssssssssssssss");
}
} 展开
配置文件:
<bean name="visitLogCollectService" class="xx.service.VisitLogCollectService" />
<bean id="jobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="visitLogCollectService" />
<property name="targetMethod" value="doCollect" />
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDetail" />
<property name="cronExpression" value="0 30 17 * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
<property name="taskExecutor" ref="executor" />
</bean>
方法:
@Service("visitLogCollectService")
public class VisitLogCollectService {
public void doCollect(){
System.out.println("sssssssssssssssssssssssssssssssssssssssssss");
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询