org.springframework.beans.ConversionNotSupportedException异常解决方法

来源:互联网 发布:苹果手机变音软件 编辑:程序博客网 时间:2024/05/19 07:25

  最近在SpringBoot项目中配置事务,结果一运行出现这个异常,当然这个异常不是由于事务引起的。

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配置如下:

    <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,这个时候实现类转换失败。

  解决方法如下:

  • 1、添加aop依赖
<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-aop</artifactId></dependency>
  • 1、applicationContext.xml文件中配置aop,注明可以用实现类注入。
<aop:config proxy-target-class="true"></aop:config>
阅读全文
1 0
原创粉丝点击