AOP自动配置

获取AOP自动配置类

在这里插入图片描述
在这里插入图片描述

解析Aop自动配置类,该导入的Bean导入

可以看到AopAutoConfiguration具有两个内部@Component类

AspectJAutoProxyingConfiguration和ClassProxyingConfiguration,并且

AspectJAutoProxyingConfiguration配置类中又有两个内部@Component类
JdkDynamicAutoProxyConfiguration
CglibAutoProxyConfiguration

在这里插入图片描述在这里插入图片描述

重点 @EnableAspectJAutoProxy(proxyTargetClass = false) 注册Creator

@Import导入AspectJAutoProxyRegistrar类
在这里插入图片描述

AspectJAutoProxyRegistrar类注册Creator

在这里插入图片描述
注册AnnotationAwareAspectJAutoProxyCreator类的Bean,它会之后作为PostProcessor来处理AOP实现
在这里插入图片描述
在这里插入图片描述

处理AOP实现在这里插入图片描述

附录
条件注解的判断

在AOP自动配置的过程中,有几个条件注解的判断

/*默认为true,在Springboot2.6.4中没有了以前的判断,默认会导入配置类AopAutoConfiguration处理。*/
@ConditionalOnProperty(prefix = "spring.aop", name = "auto", havingValue = "true", matchIfMissing = true)
public class AopAutoConfiguration {

/*需要Advice.class,需要在maven中配置依赖导入Advice类*/
@ConditionalOnClass(Advice.class)
static class AspectJAutoProxyingConfiguration {

/*默认使用CGLIB,除非你去自己修改配置*/
@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "false")
		static class JdkDynamicAutoProxyConfiguration {


@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "true",
				matchIfMissing = true)


@ConditionalOnMissingClass("org.aspectj.weaver.Advice")
	@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "true",
			matchIfMissing = true)

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
这样类路径下就有了Advice类,就说明AspectJAutoProxyingConfiguration配置类要导入使用
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值