Assuming my current package structure in a spring projects as :
com.stackoverflow |- service |- entities |- controllers |- package1 |- package2 |-util
How can I apply an aspect to all the packages under com.stackoverflow except on the package util?
Applying it to everything, the execution expression would be “com.stackoverflow...(..)”
What should the execution expression be in this case I want to remove the util subpackage from the execution expression?
Use the AND
&& and NOT
! operators in your
Pointcut expression as
@Pointcut ("execution (* com.stackoverflow..*.*(..)) && " + "!execution (* com.stackoverflow.util..*.*(..))")