<bean id="myException" class="com.sn.spring.aspect.MyException"></bean> <aop:config> <aop:pointcut expression="execution(* com.sn.spring.service.impl.*.*(..))" id="perform"/> <aop:aspect ref="myException"> <aop:after-throwing method="myExcep" pointcut-ref="perform" throwing="e"/> </aop:aspect> </aop:config>
public class MyException { public void myExcep(Throwable e) { System.out.println(e.getMessage()); } }
时间: 2024-10-10 22:40:50