Abhishek Ramachandran
Abhishek Ramachandran

Reputation: 1170

Pointcut Expression for specific methods in different packages

I tried pointcut expression for a specific package like com.abc.def.controller, com.abc.def.service.serviceImpl, etc in @Around advice as:

@Around("execution(* com.abc.def.controller..*.*(..))")
@Around("execution(* com.abc.def.service.*Impl.*(..))")

I also need to match methods in different packages like com.abc.xyz.controller, com.abc.xyz.service.serviceImpl and tried many pointcut expressions but didn't worked.

Any help will be appreciated. :)

Upvotes: 2

Views: 2473

Answers (2)

kriegaex
kriegaex

Reputation: 67317

How about this?

@Around("execution(* com.abc..controller..*(..))")
@Around("execution(* com.abc..service.*Impl.*(..))")

You can also match both at once like this:

@Around(
    "execution(* com.abc..controller..*(..)) || " + 
    "execution(* com.abc..service.*Impl.*(..))"
)

Other variants are possible, depending on what exactly you want to achieve. Feel free to ask related follow-up questions.

Upvotes: 1

Anil Agrawal
Anil Agrawal

Reputation: 3026

Try below expression for the same,

@Around("execution(* com.abc.def.controller.*.*(..))")

Upvotes: 0

Related Questions