spring-210727-04—AOP-AspectJ准备
AOP准备:
Spring框架一般都是基于AspectJ实现AOP操作,
AspectJ不是Spring组成部分,独立AOP框架,一般吧AspectJ和Spring框架一起使用,进行AOP操作。
基于AspectJ实现AOP操作:
1. 基于xml配置文件实现
2. 基于注解方式实现
在工程中引入AOP相关的依赖
切点表达式
切点表达式作用:
知道对哪个类里面的哪个方法进行增强。
语法结构:
execution([权限修饰符] [返回类型][类全路径][方法名称]([参数列表]))
案例01:
对com.bgy.dao.BookDao类里面的add方法进行增强
execution(* com.bgy.dao.BookDao.add(..))
案例02:
对com.bgy.dao.BookDao类里面的所有方法进行增强
execution(* com.bgy.dao.BookDao.*(..))
案例03:
对com.bgy.dao包里面的所有类,所有方法进行增强
execution(* com.bgy.dao.*.*(..))