从今天开始,阅读spring framework官方文档中的spring aop部分,并将要点记录如下:
通过切入点匹配的连接点的概念是AOP的关键。
spring aop默认使用标准JDK动态代理作为AOP代理,这样可以使任何一个接口(或接口集)被代理。spring aop也可以使用CGLIB代理,这对代理类是必须的,但对接口不是。默认情况下,如果一个业务类没有实现接口,就会使用CGLIB。但是在程序中使用接口而不使用类是更好的体现。
@Configuration @EnableAspectJAutoProxy public class AppConfig { }
<aop:aspectj-autoproxy/>
package org.xyz; import org.aspectj.lang.annotation.Aspect; @Aspect public class NotVeryUsefulAspect { }
@Pointcut("execution(* transfer(..))") // the pointcut expression private void anyOldTransfer() {} // the pointcut signature
原文:https://www.cnblogs.com/aleda-territory/p/12670666.html