当前位置: 代码迷 >> Java Web开发 >> 定时部署出错
  详细解决方案

定时部署出错

热度:7279   发布时间:2013-02-25 21:13:53.0
定时调度出错啊
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"/>    </bean>    <bean id="scheduledQuartzTaskTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">        <property name="jobDetail" ref="myJobProxy"/>        <property name="cronExpression" value="0 59 * * * ?"/>    </bean>        <!-- 配置任务调度按排表 -->    <bean id="quartzTiggerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">        <property name="triggers">            <list>                <ref bean="scheduledQuartzTaskTrigger"/>            </list>        </property>    </bean>
  相关解决方案