日期:2014-05-17  浏览次数:20879 次

定时调度出错啊
Error creating bean with name 'userLogin' defined in ServletContext resource [/WEB-INF/classes/spring-actions.xml]: Unsatisfied dependency expressed through bean property 'arguments': : Error creating bean with name 'QuartzCornTrigger' defined in ServletContext resource [/WEB-INF/classes/spring-actions.xml]: Cannot resolve reference to bean 'userLogin' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'userLogin': FactoryBean which is currently in creation returned null from getObject; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'QuartzCornTrigger' defined in ServletContext resource [/WEB-INF/classes/spring-actions.xml]: Cannot resolve reference to bean 'userLogin' while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'userLogin': FactoryBean which is currently in creation returned null from getObject

xml配置
<bean name = "userloginAction" class = "elkw.action.system.UserLoginAction"></bean>
<!-- 定义调度对象和调用的方法 -->
<bean id="userLogin" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="userloginAction"></property>
<property name="targetMethod">
<value>timerTask</value>
</property>
</bean>
<!-- 配置触发器 -->
<bean id="QuartzCornTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="userLogin"></property>
<!-- 触发时间(使用cron表达式) -->
<property name="cronExpression">
<value>0/5 * * * * ?</value>
</property>
</bean>
<!-- 调度程序管理类 -->
<bean id="startQuartz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<!-- 添加触发器 -->
<property name="triggers">
<list>
<ref local="QuartzCornTrigger" />
</list>
</property>
</bean>

------解决方案--------------------
quartz启动太快了,bean还没建好。延迟一下
<bean id="QuartzCornTrigger" 下加

<property name="startDelay">
<value>5000</value>
</property>

------解决方案--------------------
探讨

照下面修改一下试试。
<property name="cronExpression">
<value>55 1 * * * ?</value>
</property>
</bean>
<!-- 调度程序管理类 -->
<bean id="startQuartz" lazy-init="true" autowire="no"
class="org.springframework.sc……

------解决方案--------------------
Java code

    <!-- 通过MethodInvokingJobDetailFactoryBean实现 -->    
    <bean id="myJob" class="com.quartz.MyJob"/>
    <bean id="myJobProxy" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="myJob"/>
        <property name="targetMethod" value="test"/>
    &