日期:2014-05-20  浏览次数:20787 次

spring定时器启动了但不执行任务
application.xml中定时器相关的配置:
XML code

<bean id="mediaManager" name="mediaManager"
        class="cn.biz.datacenter.basedata.impl.MediaManager">
        <aop:scoped-proxy proxy-target-class="false" />
    </bean>
 <bean id="buildMediaList" 
       class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="mediaManager" />
      <property name="targetMethod" value="buildMediaList" />
    </bean>
<bean id="buildMediaListTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="buildMediaList" />
        <property name="cronExpression" value="10 25 17 * * ?" />
    </bean>
 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="buildMediaListTrigger" />
                
            </list>
        </property>
    </bean>



应用启动时定时器部分的启动日志:
Java code

Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
Quartz Scheduler v.1.6.5 created.
RAMJobStore initialized.
Quartz scheduler 'catcherScheduler' initialized from an externally provided properties instance.
Quartz scheduler version: 1.6.5
JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@11669f2
Starting Quartz Scheduler now
Scheduler catcherScheduler_$_NON_CLUSTERED started.
==================== Startup CatcherManager ====================
Fetch all BSD_SCHEDULE, and put them into MAP
Hibernate: select bsd_schedu0_.ID as ID43_, bsd_schedu0_.NAME as NAME43_, bsd_schedu0_.RUNNING_TYPE as RUNNING3_43_, bsd_schedu0_.RUNNING_PARAM as RUNNING4_43_, bsd_schedu0_.SCHEDULE_TYPE as SCHEDULE5_43_, bsd_schedu0_.YEAR as YEAR43_, bsd_schedu0_.MONTH as MONTH43_, bsd_schedu0_.DAY as DAY43_, bsd_schedu0_.WEEK as WEEK43_, bsd_schedu0_.HOUR as HOUR43_, bsd_schedu0_.MINUTE as MINUTE43_, bsd_schedu0_.CRON as CRON43_, bsd_schedu0_.JOB_NAME as JOB13_43_, bsd_schedu0_.PRIORITY as PRIORITY43_, bsd_schedu0_.SYSTEM_TASK as SYSTEM15_43_, bsd_schedu0_.AVAILABLE as AVAILABLE43_, bsd_schedu0_.OLD_SID as OLD17_43_ from icrom.BSD_SCHEDULE bsd_schedu0_ where bsd_schedu0_.AVAILABLE=1
Add CatcherJobListener to CatcherScheduler.
Arrange all BSD_SCHEDULE into, and put them into CatcherScheduler.
Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
Quartz Scheduler v.1.6.5 created.
RAMJobStore initialized.
Quartz scheduler 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' initialized from an externally provided properties instance.
Quartz scheduler version: 1.6.5
JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@1e9d810
Starting Quartz Scheduler now
Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED started.



根据配置,此任务应该是在下午5点25分执行的,但应用确没有执行,
请各位前辈帮忙看看是哪里出问题了!
谢谢

------解决方案--------------------
<bean id="buildMediaList" 
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="mediaManager" />
<property name="targetMethod" value="buildMediaList" />
</bean>
这里错了吧,这里是执行的函数名字,应该这样写吧
<property name="targetMethod"><value>buildMediaList</value></property> 。