<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java學習

    java學習

     

    spring中aop 的配置實現

    四種通知的執行地方:前置通知
    try{
    業務代碼
    后置通知
    } catch{
    異常通知
    } finally{
    最終通知
    }
    1.需要的jar包:aspectjrt.jar,aspectjweaver.jar,cglib-nodep-2.1.3.jar
    2.在配置文件中加入

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:p="http://www.springframework.org/schema/p"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

    ">
    <bean id="myXmlAspect" class="com.yjw.aspect.MyXmlAspect"/>
    <!-- 配置事務切面-->
    <aop:config>
     <aop:aspect ref="myXmlAspect">
      <aop:pointcut expression="execution(* com.yjw.dao..*.*(..))" id="pointcut"/>
      <aop:before method="beforeAdvice" pointcut-ref="pointcut"/>
      <aop:after-returning method="afterReturningAdvice" returning="value" pointcut-ref="pointcut"/>
      <aop:after-throwing method="exceptionAdvice" pointcut-ref="pointcut" throwing="ex"/>
      <aop:after method="afterAdvice" pointcut-ref="pointcut"/>
     </aop:aspect>
    </aop:config>
    </beans>

     

    package com.yjw.aspect;

     

     

    public class MyXmlAspect {


     
     //前置通知

     public void  beforeAdvice(){
      System.out.println("前置通知");
     }
     //異常通知,接收異常信息

     public  void  exceptionAdvice(Exception  ex){
      System.out.println("異常出現"+ex.getMessage());
     }
     //后置通知,可以接收方法的返回值
     
     public  void  afterReturningAdvice(Object  value){
      System.out.println("后置通知"+value);
     }
     //最終通知

     public  void  afterAdvice(){
      System.out.println("after");
     }
    }

     

    posted on 2013-04-29 11:50 楊軍威 閱讀(246) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    導航

    統計

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 精品国产污污免费网站| 中文日本免费高清| 久久久久久国产精品免费免费| 国产精品亚洲精品日韩已满| 久久高潮一级毛片免费| 久久精品国产亚洲Aⅴ香蕉| www免费插插视频| 亚洲乱色熟女一区二区三区丝袜| 中文在线免费视频| 亚洲AV无码乱码国产麻豆穿越| 免费在线观看一级片| 亚洲国产二区三区久久| 最近中文字幕高清免费中文字幕mv| 亚洲一二成人精品区| 永久黄色免费网站| 一本色道久久88—综合亚洲精品| 午夜色a大片在线观看免费| 亚洲AV无码一区二区三区久久精品| 国产精品久久久久影院免费| 成人午夜免费视频| 国产AV无码专区亚洲精品| **一级一级毛片免费观看| 亚洲一区二区三区在线观看网站| 国产美女无遮挡免费视频| 一级毛片免费全部播放| 亚洲av日韩av激情亚洲| 麻花传媒剧在线mv免费观看| 亚洲精品久久无码| 亚洲熟女乱综合一区二区| 久久久久国产免费| 亚洲精品理论电影在线观看| 91麻豆国产自产在线观看亚洲| 国产精品免费无遮挡无码永久视频| 亚洲一区二区三区不卡在线播放| 在线视频免费国产成人| 免费无码又爽又刺激网站| 亚洲手机中文字幕| 久久国产成人亚洲精品影院 | 在线观看亚洲免费视频| GOGOGO免费观看国语| 亚洲午夜精品一区二区公牛电影院 |