我有多个来自不同包的类,它们扩展了一个超级类。 我想创建一个 AOP 切入点,它匹配所有扩展 Super 的类中的所有方法。 我试过这个:
@Around("within(com.mypackage.that.contains.super..*)")
public void aroundAllEndPoints(ProceedingJoinPoint joinPoint) throws Throwable {
LOGGER.info("before Proceed ");
joinPoint.proceed();
LOGGER.info("after Proceed");
}
但是没用。 有什么建议吗?
切入点应该是:
within(com.mypackage.Super+)
其中
com.mypackage.Super
是完全限定的基类名称,+
表示“所有子类”。这适用于 Spring AOP。在 AspectJ 中,这会匹配太多的连接点,而不仅仅是方法执行。这是另一个适用于 Spring AOP 和 AspectJ 的切入点:
execution(* com.mypackage.Super+.*(..))