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