在下面的代码中每天只执行第一个定时器方法execFileReportJob1,后面两个定时器方法则一直未执行。
java代码:
package com.timer;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import com.service.collection.CsCollectionListService;
public class MonitoringSendJob {
@Autowired
private IALoanMass iALoanMass;
@Resource
CsCollectionListService collectionServiceImp;
public void execFileReportJob1(){
try {
/*
try{
updateCollection();
}catch (Exception e) {
e.printStackTrace();
}
try{
updateCollection2();
}catch (Exception e) {
e.printStackTrace();
}
*/
Map<String,List<Object>> dsq = iALoanMass.getParameterCIC();
collectionServiceImp.insertLSOverdue2(dsq);
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateCollection(){
try {
collectionServiceImp.updateCollection();
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateCollection2(){
try {
collectionServiceImp.updateCollection2();
} catch (Exception e) {
e.printStackTrace();
}
}
}
spring-monitoring-job.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="monitoringSendJob" class="com.timer.MonitoringSendJob"/>
<bean id="fileReportJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent" value="false"/>
<property name="targetObject" ref="monitoringSendJob" />
<property name="targetMethod" value="execFileReportJob1"/>
</bean>
<bean id="fileReportJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="fileReportJobDetail" />
<property name="misfireInstruction" value="0"></property>
<property name="startDelay" value="30000"></property>
<property name="cronExpression">
<value>0 0 5 * * ?</value>
</property>
</bean>
<bean id="updateCollectionJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent" value="false"/>
<property name="targetObject" ref="monitoringSendJob" />
<property name="targetMethod" value="updateCollection"/>
</bean>
<bean id="updateCollectionJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="updateCollectionJobDetail" />
<property name="misfireInstruction" value="0"></property>
<property name="startDelay" value="30000"></property>
<property name="cronExpression">
<value>0 0 6 * * ?</value>
</property>
</bean>
<bean id="updateCollectionsJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent" value="false"/>
<property name="targetObject" ref="monitoringSendJob" />
<property name="targetMethod" value="updateCollection2"/>
</bean>
<bean id="updateCollectionsJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="updateCollectionsJobDetail" />
<property name="misfireInstruction" value="0"></property>
<property name="startDelay" value="30000"></property>
<property name="cronExpression">
<value>0 0 7 * * ?</value>
</property>
</bean>
<!-- 任务调度 -->
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="fileReportJobTrigger"/>
<ref bean="updateCollectionJobTrigger"/>
<ref bean="updateCollectionsJobTrigger"/>
</list>
</property>
</bean>
</beans>