我在 @ 中尝试了针对特定包的切入点表达式,例如
建议为:com.abc.def.controller
、com.abc.def.service.serviceImpl
等围绕
@Around("execution(* com.abc.def.controller..*.*(..))")
@Around("execution(* com.abc.def.service.*Impl.*(..))")
我还需要匹配不同包中的方法,例如 com.abc.xyz.controller
、com.abc.xyz.service.serviceImpl
并尝试了很多切入点表达式,但是没有用。
任何帮助将不胜感激。 :)
最佳答案
这个怎么样?
@Around("execution(* com.abc..controller..*(..))")
@Around("execution(* com.abc..service.*Impl.*(..))")
您也可以像这样同时匹配两者:
@Around(
"execution(* com.abc..controller..*(..)) || " +
"execution(* com.abc..service.*Impl.*(..))"
)
其他变体也是可能的,具体取决于您想要实现的目标。欢迎提出相关的后续问题。
关于java - 不同包中特定方法的切入点表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41689828/