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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM