使用通配符实现切点表达式的设置,例如:
@Around("execution(* com.example..*.*Controller.*(..))")
public Object myAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
// advice code here
}
这里的..表示可以匹配任意子包,*Controller表示匹配类名中以Controller结尾的类,*则匹配任意方法名。这样,我们就可以对不同子包下的类中的以Controller结尾的方法进行操作了。
上一篇:AOPAdvice未执行