码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-05-27 23:38:16      阅读:1397      评论:0      收藏:0      [点我收藏+]

标签:style   c   class   blog   code   java   

   在一个业务类有下列属性

bubuko.com,布布扣
private SchedulerFactoryBeanscheduler;

    public SchedulerFactory BeangetScheduler() {
        return scheduler;
    }

    public void setScheduler(SchedulerFactoryBean scheduler) {
        this.scheduler = scheduler;
    }
bubuko.com,布布扣

用spring 进行装配:

bubuko.com,布布扣
   <property name="scheduler">
           <ref bean="schedulerFactoryBean" />
        </property>

    </bean>
    <bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"/>
bubuko.com,布布扣

启动时候报: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对象 ,

所以属性需要修改:

bubuko.com,布布扣
   private StdScheduler scheduler;

    public StdScheduler getScheduler() {
        return scheduler;
    }

    public void setScheduler(StdScheduler scheduler) {
        this.scheduler = scheduler;
    }
bubuko.com,布布扣

 

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

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

标签:style   c   class   blog   code   java   

原文地址:http://www.cnblogs.com/onmyway20xx/p/3753781.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!