用于拦截所有exception的Spring AOP配置

我正在努力编写/配置一个ThrowsAdvice拦截器,我想拦截整个项目中抛出的所有exception:

public class ExceptionsInterceptor implements ThrowsAdvice { public void afterThrowing(final Method p_oMethod, final Object[] p_oArgArray, final Object p_oTarget, final Exception p_oException) { System.out.println("Exception caught by Spring AOP!"); } } 

我已经成功配置了一个MethodInterceptor实现,它拦截了我想要分析的特定方法(看看它们执行需要多长时间)。 这是我到目前为止的XML配置文件:

        

我的ProfilingInterceptor工作得很完美,并且当我的Main :: doSomething()方法被调用时精确拦截 – 所以我知道我是ontrack。 使用XmlSpy来查看Spring AOP的模式,看起来我可以添加类似下面的内容,以便让我的ExceptionsInterceptor拦截所有抛出的exception:

    

但是我找不到任何以此为例的文档,我不知道如何配置方法属性,使其成为“通配符”(*)并匹配所有类和所有方法。

谁能指出我正确的方向? 提前致谢!

根据aspectJ示例,方法参数指的是@AfterThrowing建议方法:

 @Aspect public class LoggingAspect { @AfterThrowing( pointcut = "execution(* package.addCustomerThrowException(..))", throwing= "error") public void logAfterThrowing(JoinPoint joinPoint, Throwable error) { //... } } 

然后配置:

   

希望能帮助到你。