SpringAOP一些总结笔记

SpringAOP的一些术语意思

SpringAOP总结

  1. SpringAOP分为JDK实现和CGLib实现。虽然说SpringAOP用到了AspectJ包,但是这只是Spring借用一下AspectJ的注解以实现切入点的解析和匹配,意思是只在注解编程时AspectJ会被用到。AspectJ也是一个用于实现切面编程(AOP)的一个框架,而且有自己的编译器。
    Spring官网原文解释:

Spring interprets the same annotations as AspectJ 5, using a library supplied by AspectJ for pointcut parsing and matching. The AOP runtime is still pure Spring AOP, though, and there is no dependency on the AspectJ compiler or weaver.

  1. 默认情况下Spring使用JDK动态代理实现SpringAOP。
    理由如下(摘自Spring官网):

By default, CGLIB is used if a business object does not implement an interface. As it is good practice to program to interfaces rather than classes, business classes normally implement one or more business interfaces.

想要开启CGlib可以在xml中添加一下配置:

<aop:aspectj-autoproxy proxy-target-class="true"/>
<!--默认是false-->
  1. CGLib的一些特点:
  • 使用CGLib代理的类,不需要实现接口,因为CGlib是直接继承那个类实现的代理,这也意味这final关键字会使代理无效甚至报错
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值