Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the way that SpringBoot AOP @ Pointcut pointcut expressions exclude certain classes

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the way that SpringBoot AOP @ Pointcut pointcut expressions exclude certain classes". In daily operations, I believe many people have doubts about what is the way SpringBoot AOP @ Pointcut pointcut expressions exclude certain classes. Xiaobian consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the doubts of "SpringBoot AOP @ Pointcut pointcut expressions excluding certain classes". Next, please follow the editor to study!

SpringBoot AOP @ Pointcut pointcut expression excludes certain class scenarios

You want to add starting and ending info log to all public methods under the service package, but you need to exclude database-related service

All other blog posts are recommended.

@ Pointcut ("execution (* com.demo.service.*.* (..)) & &! execution (* com.demo.service.dbservice.* (..)")

Similar usage, but in practice, it is found that the & & keyword cannot be used and can only be compiled using and, and @ Pointcut only recognizes the first half of the expression, and the content after and (& &) is ignored.

The following methods are used to meet the development requirements @ Pointcut ("execution (public * com.demo.service.*.* (..)") Public void serviceMethods () {} @ Pointcut ("execution (public * com.demo.service.dbservice.* (..)") Public void serviceMethods2 () {} @ Pointcut ("serviceMethods () & &! serviceMethods2 ()") public void serviceMethods3 () {} @ Before ("serviceMethods3 ()") public void startLog (JoinPoint joinPoint) {String className = joinPoint.getSignature (). GetDeclaringType (). GetSimpleName (); String methodName = joinPoint.getSignature (). GetName (); logger.info ("{}. {} start", className, methodName) } AOP excludes some types that do not intercept / * logging aspects * / @ Aspectpublic class Logger implements ILogger {@ Resource (name= "logService") private LogService logService; @ Pointcut ("execution (* *. * Action*.* (..)) & &! execution (* com.audaque.tjfxpt.web.sjcx.LogAction.* (..)") Public void actionPointCut () {} at this point, the study of "what is the way SpringBoot AOP @ Pointcut pointcut expressions exclude certain classes" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report