王小二的包菜君 2017-03-07 03:56 采纳率: 0%
浏览 1489

关于SpringMVC项目中quartz定时器只执行第一个

在下面的代码中每天只执行第一个定时器方法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>


  • 写回答

2条回答 默认 最新

  • devmiao 2017-03-07 15:46
    关注
    评论

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?