参考地址:https://stackoverflow.com/questions/38822971/spring-aop-exclude-some-classes
官方文档:https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#aop
Example
@Around("execution(* com.foo.bar.web.controller.*.*(..)) "+ "&& !@annotation(com.foo.bar.util.NoLogging) "+ "&& !@target(com.foo.bar.util.NoLogging)")public Object log(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {// 切面逻辑}
Explanation
execution(* com.foo.bar.web.controller.*.*(..))all methods of all classes in
c.f.b.w.controllerpackage
—— 切点:com.foo.bar.web.controller包下所有的类和方法"&& !@annotation(com.foo.bar.util.NoLogging)"
—— 排除:带有@NoLogging注解的方法
"&& !@target(com.foo.bar.util.NoLogging)"
—— 排除:带有@NoLogging注解的类的所有方法
