Spring 异常关键字 no matching editors or conversion strategy found 解决方法
异常信息如下:
Error creating bean with name 'sysLogAction' defined in file [E:\Workspace\eoms\ultrawf\WebRoot\WEB-INF\classes\spring\bjeoms-sysinfo.xml]: Cannot resolve reference to bean 'sysLogService' while setting bean property 'sysLogService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysLogService' defined in file [E:\Workspace\eoms\ultrawf\WebRoot\WEB-INF\classes\spring\bjeoms-sysinfo.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ultrapower.eoms.common.dao.impl.HibernateDaoImpl] to required type [com.ultrapower.bjeoms.common.core.dao.IHibernateDao] for property 'hibernateDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ultrapower.eoms.common.dao.impl.HibernateDaoImpl] to required type [com.ultrapower.bjeoms.common.core.dao.IHibernateDao] for property 'hibernateDao': no matching editors or conversion strategy found
相关配置信息如下:
【bjeoms-sysinfo.xml】
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans default-autowire="byName" default-lazy-init="true"> <!-- 系统日志信息 syslog start --> <bean id="sysLogAction" class="com.ultrapower.bjeoms.syslog.action.BJEomsSysLogAction" /> <bean id="sysLogService" class="com.ultrapower.bjeoms.syslog.manager.BJEomsSysLogServiceImpl" /> <!-- 系统日志信息 syslog end --> </beans>
【dataAccessContext-hibernate.xml】
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans default-autowire="byName" default-lazy-init="true"> <bean > 。。。 。。。 </bean> <!--Hibernate TransactionManager--> <bean id="appSessionFactory" class="cn.com.ultrapower.eoms.common.basedao.GeneralDAO" lazy-init="false"> <property name="hibernateSessionFactory" ref="sessionFactory" /> </bean> <bean id="baseSessionFactory" class="cn.com.ultrapower.eoms.user.comm.hibernatesession.HibernateSessionFactory" lazy-init="false"> <property name="hibernateSessionFactory" ref="sessionFactory" /> </bean> <bean id="hibernateDao" class="com.ultrapower.eoms.common.dao.impl.HibernateDaoImpl"/> <bean id="bjIDao" class="com.ultrapower.bjeoms.common.core.dao.impl.HibernateDaoImpl"/> </beans>
异常说明 :在使用id="bjIDao"的实现类时,由于实现类中的set方法没有写成setBjIDao,而是copy bean id="hibernateDao"的setHibernateDao,导致映射的类不匹配。
在功能迁移时,ctrl+c、ctrl+v 时要小心 ,注意~~~