2

我有自己的异常“MyOwnException”并从我的服务类中抛出此异常

public void service() throws MyOwnException
{
// some code 

}

现在我想在建议中捕获 MyOwnException 并重新抛出一个全新的异常

public class SimpleThrowsAdvice implements ThrowsAdvice {

    public void afterThrowing(Method method, Object[] args, Object target,
                MyOwnException ex) throws Throwable {
        throw new Exception("new Description",ex);
    }
}

Exception现在,我怎样才能从上述建议中重新抛出SimpleThrowsAdvice

4

1 回答 1

4

你应该使用 Around 建议来做到这一点。参见这里Spring AOP AfterThrowing vs. Around Advice

于 2010-08-03T09:28:00.017 回答