SpringAop的几种匹配方式

within表达式

匹配表达式类中的所有方法

@Pointcut("within(com.example.springbootdemo.Controller.TestController)")

匹配TestController类中的所有方法

execution表达式

  • 修饰符 可选
  • 返回值 必须为包名全称
  • 类路径 可选
  • 方法名 必须为包名全称
  • 参数
  • 异常类型 可选

@Pointcut("execution(com.example.springbootdemo.pojo.Person com.example.springbootdemo.Controller.TestController.test())")

对象匹配

  • this
  • target
  • bean

参数匹配

注解匹配

自定义注解进行aop拦截

赏个🍗吧
0%