Search code examples
springpointcut

Spring pointcut involving ignoring a class


I have a point cut for all classes in Spring AOP like

@Pointcut("execution(* com.company.app..*(..))")

Now I need to exclude a class say com.company.app.IgnoreClass. Can someone please help me write the pointcut?


Solution

  • The Pointcut to exclude all methods in IgnoreClass would be:

    @Pointcut("execution(* com.company.app..*(..)) && !execution(* com.company.app.IgnoreClass.*(..)) ")
    

    Documentation about pointcuts expression here, also more related information on Spring AOP declaring pointcuts here.