关于Failed to convert property value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFactoryBean

   在一个业务类有下列属性

private SchedulerFactoryBeanscheduler;

    public SchedulerFactory BeangetScheduler() {
        return scheduler;
    }

    public void setScheduler(SchedulerFactoryBean scheduler) {
        this.scheduler = scheduler;
    }

用spring 进行装配:

   <property name="scheduler">
           <ref bean="schedulerFactoryBean" />
        </property>

    </bean>
    <bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"/>

启动时候报:Failed to convert property value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFactoryBean异常

解决方案:

SchedulerFactoryBean 这个bean
<bean id="Scheduler" lazy-init="false" autowire="no" 
class="org.springframework.scheduling.quartz.SchedulerFactoryBean" > 
</bean> 
它是一个工厂bean,得到的不是它本身,而是它负责创建的org.quartz.impl.StdScheduler对象 ,

所以属性需要修改:

   private StdScheduler scheduler;

    public StdScheduler getScheduler() {
        return scheduler;
    }

    public void setScheduler(StdScheduler scheduler) {
        this.scheduler = scheduler;
    }

 

关于Failed to convert property value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFactoryBean,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。