文章目录
EnableAspectJAutoProxy 开启AOP
开启AOP功能可用注解形式开启:
@EnableAspectJAutoProxy
看下@EnableAspectJAutoProxy注解的作用
由上图源码可知,EnableAspectJAutoProxy注解导入了AspectJAutoProxyRegist类。
AspectJAutoProxyRegistrar类分析
分析下AspectJAutoProxyRegist类的作用。
AspectJAutoProxyRegist类继承了ImportBeanDefinitionRegistrar。
class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar
会在spring ioc 扫描类定义的过程中调用里面的registerBeanDfinitions方法。
然后通过AopConfigUtils工具类在IOC容器中注册了AnnotationAwareAspectAutoProxyCreator类