使用注解匹配Spring Aop切点表达式

Spring中的类基本都会标注解,所以使用注解匹配切点可以满足绝大部分需求

主要使用@within()/@target @annotaton() @args()等...

匹配@Service类中的所有方法:

@within(org.springframework.stereotype.Service)

 或

@target(org.springframework.stereotype.Service)

匹配标注了@RequestMapping的所有方法

@annotation(org.springframework.web.bind.annotation.RequestMapping)

匹配参数中有@RequestBody的所有方法

@args(org.springframework.web.bind.annotation.RequestBody)

注:有关注解的AspectJ指示器只作用于目标Class,即当这类指示器指向interface时,不能匹配实现类

原文地址:https://www.cnblogs.com/niceboat/p/6126558.html