使用注解匹配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时,不能匹配实现类

 

posted @ 2016-12-02 18:22  傅晓芸  阅读(4634)  评论(0编辑  收藏  举报