使用注解匹配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