aop @AfterThrowing不执行

J2EE 码拜 9年前 (2015-04-09) 3103次浏览 0个评论

运行@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)

aop @AfterThrowing不执行
大神
aop @AfterThrowing不执行
为什么大神还没来
aop @AfterThrowing不执行
40分
execution(* com.sarkuya.service..*.*(..))

你写错包名了,

“execution(* com.asrkuya.service..*.*(..))

aop @AfterThrowing不执行
引用 3 楼 sc6231565 的回复:

execution(* com.sarkuya.service..*.*(..))

你写错包名了,

“execution(* com.asrkuya.service..*.*(..))

汗颜,感谢大神!


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明aop @AfterThrowing不执行
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!