定时调度出错啊

时间:2022-09-22 07:59:06
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>

11 个解决方案

#1


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

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

#2


还是这个错,不行,
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

#3


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

#4


定时调度出错啊还不行。。谢谢你了

#5


定时调度出错啊还那样,谢谢你了

#6


定时调度出错啊还那样,谢谢你了

#7


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


没有作用哈。

#8



<!-- 通过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>

#9


引用 8 楼  的回复:
Java code

    <!-- 通过MethodInvokingJobDetailFactoryBean实现 -->    
    <bean id="myJob" class="com.quartz.MyJob"/>
    <bean id="myJobProxy" class="org.springframework.scheduling.quartz.MethodInvoki……


当然知道这样配置,关键是我配置的是多任务。

#10


Error creating bean with name 'userLogin': FactoryBean which is currently in creation returned null from getObject

你确信你的userLogin配置是正确的吗?

#11


终于解决了。哇咔咔。多任务配置时,每个bean要参照不同的SchedulerFactoryBean。

如下:


     <bean id="scheduleInfoManager" class="com.springquartz.service.ScheduleInfoManager">
          <property name="scheduler" ref="schedulerFactory"/>
     </bean>
     
     <!-- 添加执行任务 -->
      
     <bean id="excuteJobBean" class="com.springquartz.service.ExecuteJobBean"> 
      <property name="scheduler" ref="jobFactory"/>
     </bean>
     
     
     <bean id="schedulerJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
         <property name="targetObject" ref="scheduleInfoManager"/>
         <property name="targetMethod" value="reScheduleJob"/>
         <property name="concurrent" value="false"/>
     </bean>
     
     <bean id="executeJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="excuteJobBean"/>
      <property name="targetMethod" value="excuteJob"/>
      <property name="concurrent" value="false"/>
     </bean>
      
     
     <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean" >
          <property name="jobDetail" ref="schedulerJobDetail"/>
          <property name="cronExpression">
            <value>0/10 * * * * ?</value>
          </property>
     </bean>
      
      <bean id="executeCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
       <property name="jobDetail" ref="executeJobDetail"/>
       <property name="cronExpression">
       <value>* 0/1 * * * ?</value>
       </property>
      </bean>
       
    
     <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false" autowire="no" >
         <property name="triggers">
             <list>
                 <ref bean="cronTrigger"/>
             </list>
         </property>
</bean>

<bean id="jobFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="executeCronTrigger"/>
</list>
</property>
</bean>

#1


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

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

#2


还是这个错,不行,
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

#3


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

#4


定时调度出错啊还不行。。谢谢你了

#5


定时调度出错啊还那样,谢谢你了

#6


定时调度出错啊还那样,谢谢你了

#7


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


没有作用哈。

#8



<!-- 通过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>

#9


引用 8 楼  的回复:
Java code

    <!-- 通过MethodInvokingJobDetailFactoryBean实现 -->    
    <bean id="myJob" class="com.quartz.MyJob"/>
    <bean id="myJobProxy" class="org.springframework.scheduling.quartz.MethodInvoki……


当然知道这样配置,关键是我配置的是多任务。

#10


Error creating bean with name 'userLogin': FactoryBean which is currently in creation returned null from getObject

你确信你的userLogin配置是正确的吗?

#11


终于解决了。哇咔咔。多任务配置时,每个bean要参照不同的SchedulerFactoryBean。

如下:


     <bean id="scheduleInfoManager" class="com.springquartz.service.ScheduleInfoManager">
          <property name="scheduler" ref="schedulerFactory"/>
     </bean>
     
     <!-- 添加执行任务 -->
      
     <bean id="excuteJobBean" class="com.springquartz.service.ExecuteJobBean"> 
      <property name="scheduler" ref="jobFactory"/>
     </bean>
     
     
     <bean id="schedulerJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
         <property name="targetObject" ref="scheduleInfoManager"/>
         <property name="targetMethod" value="reScheduleJob"/>
         <property name="concurrent" value="false"/>
     </bean>
     
     <bean id="executeJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="excuteJobBean"/>
      <property name="targetMethod" value="excuteJob"/>
      <property name="concurrent" value="false"/>
     </bean>
      
     
     <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean" >
          <property name="jobDetail" ref="schedulerJobDetail"/>
          <property name="cronExpression">
            <value>0/10 * * * * ?</value>
          </property>
     </bean>
      
      <bean id="executeCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
       <property name="jobDetail" ref="executeJobDetail"/>
       <property name="cronExpression">
       <value>* 0/1 * * * ?</value>
       </property>
      </bean>
       
    
     <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false" autowire="no" >
         <property name="triggers">
             <list>
                 <ref bean="cronTrigger"/>
             </list>
         </property>
</bean>

<bean id="jobFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="executeCronTrigger"/>
</list>
</property>
</bean>