当前位置: 代码迷 >> Java相关 >> spring定时器配置,该怎么处理
  详细解决方案

spring定时器配置,该怎么处理

热度:99   发布时间:2016-04-22 21:10:13.0
spring定时器配置
spring配置如下:
<!-- 配置时间触发器 -->
    <bean id="timer" class="com.jeecms.tongji.StatTimer">
        <property name="statDao" ref="statDao"></property>
    </bean>
    
    <bean id="statTimer" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
          <ref bean="timer"/>
        </property>
        <property name="targetMethod"> 
          <value>work</value>
        </property>
    </bean>
    <bean id="timingDevice" class="org.springframework.scheduling.quartz.CronTriggerBean">
          <property name="jobDetail">
            <ref bean="startTimer"/>
          </property>
          <property name="cronExpression">
            <value>0 0 8,14 * * ?</value>
          </property>
    </bean>
    <bean id="doScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
       <property name="triggers">
         <list>
            <ref local="timingDevice"/>
         </list>
       </property>
    </bean>

报错:
09:25:53.551 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'doScheduler' defined in ServletContext resource [/WEB-INF/config/application-context.xml]: Cannot resolve reference to bean 'timingDevice' while setting bean property 'triggers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'timingDevice' defined in ServletContext resource [/WEB-INF/config/application-context.xml]: Cannot resolve reference to bean 'startTimer' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'startTimer' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.getLifecycleBeans(DefaultLifecycleProcessor.java:273) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:125) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
  相关解决方案