切面AfterThrowing不执行
写了一个异常收集的方法
public void afterThrowing(Throwable ex) {
System.out.println("1111111111111111111111111111");
......
}
以上切面我配置在了service层的所有类
1、如果我从定时任务调用service层的方法,手动跑出一个异常
throw new Exception("1111111111111111111111");
是可以进入到 afterThrowing(Throwable ex) 这个方法中的
2、我从Controller层调用service层的方法,然后手动抛出异常
throw new Exception("1111111111111111111111");
为什么没有进入到afterThrowing方法中呢?
配置文件如下:
<bean id="throwsInterceptor" class="com.xxx.ThrowsAopInterceptor"></bean>
<aop:config>
<aop:pointcut expression="execution(* com.ddd..*(..))" id="servicePointcut"/>
<aop:aspect id="throwsAspect" ref="throwsInterceptor">
<aop:after-throwing throwing="ex" method="afterThrowing" pointcut-ref="servicePointcut" />
</aop:aspect>
</aop:config>
求指教,谢谢!