org.springframework.beans.ConversionNotSupportedException異常解決方法

  最近在SpringBoot項目中配置事務,結果一運行出現這個異常,固然這個異常不是因爲事務引發的。web

org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.sun.proxy.$Proxy54 implementing com.loongshawn.service.RfqService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised

這裏寫圖片描述

  Spring beans.xml配置以下:spring

<bean id="readExcel" class="com.loongshawn.method.pms.ReadExcel"/>

    <bean id="rfqService" class="com.loongshawn.service.impl.RfqServiceImpl"/>

    <bean id="rfqSourceFileValidService" class="com.loongshawn.service.impl.RfqSourceFileValidServiceImpl"/>

    <bean id="rfqFileUpload" class="com.loongshawn.method.pms.RfqFileUpload">
        <property name="readExcel" ref="readExcel"/>
        <property name="rfqService" ref="rfqService"/>
        <property name="rfqSourceFileValidService" ref="rfqSourceFileValidService"/>
    </bean>

  rfqFileUpload bean的傳入參數rfqService,而這個bean是RfqService接口的實現類RfqServiceImpl,這個時候實現類轉換失敗。app

  解決方法以下:svg

  • 一、添加aop依賴
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>
  • 一、applicationContext.xml文件中配置aop,註明能夠用實現類注入。
<aop:config proxy-target-class="true"></aop:config>