13_Spring_AOPXML方式实现_了解

13_Spring_AOPXML方式实现_了解

1、创建两个类,增强类和被增强类,创建方法

见之前的代码

2、在spring配置文件中创建两个类对象

  1.  

3、在spring配置文件中配置切入点

  1.  <aop:config>
    
  2.      <!--切入点-->
    
  3.      <aop:pointcut id="pointCutAdd" expression="execution(*
    
    com.msb.dao.UserDao.add*(..))"/>
  4.      <!--配置切面-->
    
  5.      <aop:aspect ref="daoAspect">
    
  6.          <!--增强作用在具体的方法上-->
    
  7.          <aop:before method="methodBefore" pointcut-ref="pointCutAdd"/>
    
  8.          <aop:after method="methodAfter" pointcut-ref="pointCutAdd"/>
    
  9.         <aop:around method="methodAround" pointcut-ref="pointCutAdd"/>
    
  10.         <aop:after-returning method="methodAfterReturning" 
    
    pointcut-ref="pointCutAdd" returning="res"/>
  11.         <aop:after-throwing method="methodAfterThrowing" 
    
    pointcut-ref="pointCutAdd" throwing="ex"/>
  12.     </aop:aspect>
    
  13. </aop:config> 
    

Generated with Mybase Desktop 8.2.13

posted @   AidenDong  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示