不同包中特定方法的切入点表达式

时间:2017-01-17 05:47:15

标签: java aop aspectj spring-aop

我在com.abc.def.controller建议中尝试了com.abc.def.service.serviceImpl@Around等特定包的切入点表达式:

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

我还需要匹配不同包中的方法,例如com.abc.xyz.controllercom.abc.xyz.service.serviceImpl并尝试了许多切入点表达式,但没有用。

任何帮助将不胜感激。 :)

2 个答案:

答案 0 :(得分:1)

这个怎么样?

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

您也可以像这样同时匹配两者:

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

其他变体是可能的,具体取决于您想要达到的目标。随意提出相关的后续问题。

答案 1 :(得分:0)

尝试以下表达式,

  

@Around(“execution(* com.abc.def.controller。*。*(..))”)