Spring2中aop的使用及遇到的一些问题
2016-11-07 09:11
253 查看
aop在spring中有两中实现的方式一种是xml,一种是基于注解的,我主要通过xml方式来实现 首先是要引入相关的jar包,如aspectjrt.jar,aspectjweaver.jar <bean id="aaa" class="aaa"></bean> <aop:config> <aop:aspect ref="aaa"> <aop:pointcut id="login" expression="execution(* bbbbbb*.checkLogin*(..))"/> <aop:after-returning method="loginLog" pointcut-ref="login"/> </aop:aspect> </aop:config> execution(* bbbbbb*.checkLogin*(..) * 返回类型 bbbbbb* 包路径 checkLogin* 方法名 .. 参数 method="loginLog" aaa中调用方法 pointcut-ref="login" target方法 execution(* *(..)) and !execution(* *(..)) 包含并且不包含指定路径中方法 aop:after-returning 方法之后调用 aop:around 方法前后 aop:before 调用之前 aop:throw 异常之后 在拦截方法时,原方法如果有异常抛出,要捕捉业务异常,并继续抛出 注意在指定包中存在的方法重名的现象 在websphere环境中,加入aop之后,带来了循环依赖的问题,因为在原有的程序中,存在着循环依赖的情况, 在没有加入aop之后,没有显现,加入之后,则出现 has been injected into other beans xxxxx in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example 最终去掉了引用,建立新的第三方对象,解决这个问题.
相关文章推荐
- VC 使用过程中所遇到的一些问题,汇总在这里,希望对后来者有些许帮助
- 使用webchart过程中遇到的一些问题
- .net在使用Lucene中遇到的一些问题总结
- 关于IIS在使用中遇到的一些问题的总结
- [项目过程中所遇到的各种问题记录]ORM篇——使用NHibernate配置对象实体的一些小问题
- log4net使用中遇到的一些问题
- 使用desinger时遇到的一些问题的处理分享
- 使用Linq 更新数据库时遇到的一些问题及解决办法
- 使用GridView时遇到的一些小问题及解决方法
- Struts2.1.8 验证框架(validation)的使用中遇到的一些问题(直接访问jsp遇到的错误)
- 使用ajax遇到的一些小问题
- 使用 spring aop 在DispatchAction中遇到的问题
- 在使用Struts的过程中也遇到了一些问题,现在总结一下
- 使用LWUIT中遇到的一些问题
- SQLSERVER2000使用中遇到的一些小问题,不断更新中。。。
- 关于用c生成的dll在使用其他供应商的工具创建可执行模块时遇到的一些问题
- 使用自动生成Mipmap时遇到的一些问题
- 使用 swfupload 遇到的一些问题
- 使用webchart过程中遇到的一些问题
- [项目过程中所遇到的各种问题记录]ORM篇——使用NHibernate配置对象实体的一些小问题