当前位置: 代码迷 >> J2EE >> exception is org.springframework.beans.TypeMismatchException:
  详细解决方案

exception is org.springframework.beans.TypeMismatchException:

热度:546   发布时间:2016-04-22 03:33:43.0
spring事务配置问题请教!
以下配置会出现找不到servlet错误,在log4j中有以下信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoProxy' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error converting typed String value for bean property 'beanNames' with key [0]; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert value of type [java.lang.String] to required type [com.auth.dao.ClerkDAO]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.auth.dao.ClerkDAO] for property 'null': no matching editors or conversion strategy found
Caused by: 
org.springframework.beans.TypeMismatchException: Failed to convert value of type [java.lang.String] to required type [com.auth.dao.ClerkDAO]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.auth.dao.ClerkDAO] for property 'null': no matching editors or conversion strategy found
Caused by: 
java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.auth.dao.ClerkDAO] for property 'null': no matching editors or conversion strategy found
XML code
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">          <property name="sessionFactory">             <ref local="sessionFactory" />          </property>    </bean><bean id="ClerkDAO" class="com.auth.dao.ClerkDAO">        <property name="sessionFactory">            <ref bean="sessionFactory" />        </property>    </bean> <bean id="transactionInterceptor"         class="org.springframework.transaction.interceptor.TransactionInterceptor">         <property name="transactionManager">             <ref local="transactionManager" />         </property>         <property name="transactionAttributes">             <props>                 <prop key="save*">PROPAGATION_REQUIRED</prop>                 <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>                 <prop key="*">PROPAGATION_REQUIRED</prop>             </props>         </property>     </bean>         <bean id="autoProxy"         class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">         <property name="beanNames">             <ref local="ClerkDAO" />         </property>         <property name="interceptorNames">             <list>                 <value>transactionInterceptor</value>             </list>         </property>     </bean>


是DAO在代理类里的类型问题吗?看书上好像都是这样的?

------解决方案--------------------
xml里有没有sessionFacory的配置?
com.auth.dao.ClerkDAO有没有(注意大小写)?
ClerkDAO 有没有继承HibernateDaoSupport?
------解决方案--------------------
前几天看到有人问 这么写不行的是不是你?
<value="classpath:hibernate.cfg.xml">

把这个里面的东东移到spring配置文件里
  相关解决方案