美文网首页
29、Spring5之AOP操作-准备工作

29、Spring5之AOP操作-准备工作

作者: 诚实可靠小郎俊 | 来源:发表于2022-07-29 09:08 被阅读0次

AOP操作(准备)

1、Spring框架一般都是基于AspectJ实现AOP操作。

什么是AspectJ
  • AspectJ不是Spring组成部分,独立AOP框架,一般把AspectJ和Spring框架一起使用,进行AOP操作

2、基于AspectJ实现AOP操作

(1)基于xml配置文件实现
(2)基于注解方式实现(使用)

3、在项目工程里面引入AOP相关依赖

spring-aop-5.2.6.RELEASE.jar
spring-aspects-5.2.6.RELEASE.jar,
com.springsource.net.sf.cglib-2.2.0.jar
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

4、切入点表达式

(1)切入点表达式作用:知道对哪个类里面的哪个方法进行增强
(2)语法结构:
execution([权限修饰符][返回类型][类全路径][方法名称]([参数列表]))
  • 举例1:对com.atguigu.dao.BookDao类里面的add进行增强
execution(* com.atguigu.dao.BookDao.add(..));
  • 举例2:对com.atguigu.dao.BookDao类里面的所有的方法进行增强
execution(* com.atguigu.dao.BookDao.*(..));
  • 举例3:对com.atguigu.dao包里面所有类,类里面所有方法进行增强
execution(* com.atguigu.dao.*.*(..));

相关文章

网友评论

      本文标题:29、Spring5之AOP操作-准备工作

      本文链接:https://www.haomeiwen.com/subject/ftyxwrtx.html