Spring使用问题记录--but was actually of type 'com.sun.proxy.$Proxy62'

这篇博客记录了在使用Spring时遇到的'but was actually of type 'com.sun.proxy.$Proxy62''错误的解决过程。通过堆栈信息分析,提出两种解决方案:一是注解方式,添加@EnableAspectJAutoProxy并设置proxyTargetClass属性;二是配置文件方式,调整代理相关配置。同时,博主还分享了@EnableAspectJAutoProxy注解的源码理解,帮助读者深入掌握问题本质。
摘要由CSDN通过智能技术生成

堆栈信息

2020-01-15T16:42:18.935+08:00 WARN xxxxxx
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: xxxxx but was actually of type 'com.sun.proxy.$Proxy62'
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1257)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
	... 53 common frames omitted

问题解决方式

  1. 注解方式
    在这里插入图片描述
  2. 第一种配置文件方式
<!--开启基于注解的事务,使用xml配置形式的事务(必要主要的都是使用配置式)  -->
<aop:config>
	<!-- 切入点表达式 -->
	<aop:pointcut expression="execution(* com.qihang.service..*(..))" id="txPoint"/>
	<!-- 配置事务增强 -->
	<aop:advisor advice-ref="txAdvice" pointcut-ref="tx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值