Spring AOP中强制使用CGLIB代理

本文介绍了Spring AOP的相关配置,包括XML和注解方式,并指出在Spring Boot中启用AOP的默认配置属性。当需要强制使用CGLIB代理时,提供了相应的配置方法。同时,文章提醒读者Spring AOP不支持代理类内部方法调用的拦截问题,这个问题可能会导致切面拦截失败。
摘要由CSDN通过智能技术生成

spring官方文档中关于aop的描述如下:

Spring AOP defaults to using standard JDK dynamic proxies for AOP proxies. This enables any interface (or set of interfaces) to be proxied.

Spring AOP can also use CGLIB proxies. This is necessary to proxy classes rather than interfaces. CGLIB is used by default if a business object does not implement an interface. As it is good practice to program to interfaces rather than classes; business classes normally will implement one or more business interfaces. It is possible to force the use of CGLIB, in those (hopefully rare) cases where you need to advise a method that is not declared on an interface, or where you need to pass a proxied object to a method as a concrete type.

(来源:http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/aop.html

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值