使用SpringMVC報錯 Error creating bean with name 'conversionService' defined in class path resource [springmvc.xml]


使用SpringMVC報錯 Error creating bean with name 'conversionService' defined in class path resource [springmvc.xml]

Could not instantiate bean class [org.springframework.core.convert.support.ConversionServiceFactory]:

Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'conversionService' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'conversionService' defined in class path resource [springmvc.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.core.convert.support.ConversionServiceFactory]: Is it an abstract class?; nested exception is java.lang.InstantiationException。

仔細檢查是springmvc.xml中的bean中的class引入錯誤的類了。比如原來是這樣的:

<bean id="conversionService"
        class="org.springframework.core.convert.support.ConversionServiceFactory">
        <property name="converters">
            <set>
                <ref bean="employeeConverter"/>
            </set>
        </property>
</bean>

正確的應該下面這樣

<bean id="conversionService"
        class="org.springframework.context.support.ConversionServiceFactoryBean">
        <property name="converters">
            <set>
                <ref bean="employeeConverter"/>
            </set>
        </property>
</bean>

修改成這樣就不會報錯了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM