aop @AfterThrowing不执行,求大神指教

n_rts 2014-10-13 03:31:56
运行@Before@After@Around都是好的,但是@AfterThrowing不执行。下面是代码:
*************************************************************************************************
@Aspect
public class PointcutsDefinition {
@AfterThrowing(value="execution(* com.asrkuya.service..*.*(..))",argNames="exception",throwing="exception")
public void afterThrowingAdvice(Exception exception){
System.out.println("hello");
System.out.println("=============after throwing advice exception:"+exception);
}
}
******************************************************************************************************
public class TestService {
public void justTest(String outString){
System.out.println(outString);
throw new RuntimeException();
}
public static void main(String [] args){
ApplicationContext ctx=new FileSystemXmlApplicationContext("config/ApplicationContext.xml");
TestService ts=(TestService) ctx.getBean("test");
ts.justTest(" hello world!");
System.exit(0);
}
}
************************************************************************************************************
<aop:aspectj-autoproxy/>
<!--
<bean class="com.sarkuya.aop.advice.SampleAdvice"></bean>
-->
<bean class="com.sarkuya.aop.pointcut.PointcutsDefinition"></bean>
<bean id="test" class="com.sarkuya.service.TestService"></bean>
****************************************************************************************************************
运行结果:
hello world!
Exception in thread "main" java.lang.RuntimeException
at com.sarkuya.service.TestService.justTest(TestService.java:9)
at com.sarkuya.service.TestService.main(TestService.java:14)
...全文
1065 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
n_rts 2014-10-14
  • 打赏
  • 举报
回复
引用 3 楼 sc6231565 的回复:
execution(* com.sarkuya.service..*.*(..)) 你写错包名了, "execution(* com.asrkuya.service..*.*(..))
汗颜,感谢大神!
Magical茏 2014-10-13
  • 打赏
  • 举报
回复
execution(* com.sarkuya.service..*.*(..)) 你写错包名了, "execution(* com.asrkuya.service..*.*(..))
n_rts 2014-10-13
  • 打赏
  • 举报
回复
为什么大神还没来
n_rts 2014-10-13
  • 打赏
  • 举报
回复
大神

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧