【第六章】 AOP 之 6.4 基于@AspectJ的AOP ——跟我学spring3
? ? ? ?Spring除了支持Schema方式配置AOP,还支持注解方式:使用@AspectJ风格的切面声明。
6.4.1? 启用对@AspectJ的支持?????? Spring默认不支持@AspectJ风格的切面声明,为了支持需要使用如下配置:
?
?
5、在chapter6/advice2.xml配置文件中进行如下配置:
?
???
其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationAfterReturningAdvice测试方法。
?
三、后置异常通知:使用org.aspectj.lang.annotation 包下的@AfterThrowing注解声明;
?
?
其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationAfterThrowingAdvice测试方法。
?
四、后置最终通知:使用org.aspectj.lang.annotation 包下的@After注解声明;
?
?
? ? ? ?value:匹配需要引入接口的目标对象的AspectJ语法类型表达式;与Schema方式中的types-matching属性同义;
? ? ? ?private Interface interface:指定需要引入的接口;
? ? ? ?defaultImpl:指定引入接口的默认实现类,没有与Schema方式中的delegate-ref属性同义的定义方式;
?
@DeclareParents( value="cn.javass..*.IHelloWorldService+", defaultImpl=cn.javass.spring.chapter6.service.impl.IntroductiondService.class)private IIntroductionService introductionService;?
?????? 其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationIntroduction测试方法。
?
原创内容,转载请注明出处【http://sishuok.com/forum/blogPost/list/0/2471.html】
1 楼 whatfangfang 2012-03-29 哥们问个问题:Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethods我查了资料,有的说是aspectj.jar 的版本低,后来我把aspectj升级到aspectj-1.6.12.jar
后我的问题依然存在
我用的是spring3+aspectj-1.6.12.jar 请问怎样解决这个问题? 2 楼 jinnianshilongnian 2012-03-29 whatfangfang 写道哥们问个问题:Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethods
我查了资料,有的说是aspectj.jar 的版本低,后来我把aspectj升级到aspectj-1.6.12.jar
后我的问题依然存在
我用的是spring3+aspectj-1.6.12.jar 请问怎样解决这个问题?
can't find referenced pointcut allMethods
找不到 切入点 allMethods 能否代码发一下 3 楼 whatfangfang 2012-03-29 给你发信息了啊,你确认下,谢谢! 4 楼 kimifdw 2012-04-09 很不错,支持一下 5 楼 jinnianshilongnian 2012-04-09 kimifdw 写道很不错,支持一下
谢谢