javaspringaopaspectjpointcut

I am trying to make a pointcut. but its giving an Exception


here i am using a point cut annotation as follows:


    @Pointcut("Execution(* com.luv2code.springdemo.controller.*.*(..))")
    private void forControllerPackage() {
        
    }

it giving me an exception which is as:

Pointcut is not well-formed: expecting ')' at character position 12
Execution(* com.luv2code.springdemo.dao.*.*(..))
            ^^^                                

I have just started learning AOP any suggestion or help is going to help a lot thanks.


Solution

  • You need to spell execution in all lower-case characters:

    @Pointcut("execution(* com.luv2code.springdemo.controller.*.*(..))")
    private void forControllerPackage() {}
    

    BTW, if you want to make sure that subpackages of com.luv2code.springdemo.controller are also covered, please use the .. syntax as follows:

    @Pointcut("execution(* com.luv2code.springdemo.controller..*(..))")
    private void forControllerPackage() {}