qqjianyue代碼工

          砌java代碼
          posts - 62, comments - 9, trackbacks - 0, articles - 10
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          spring配置事務管理器注意

          Posted on 2008-08-30 00:01 Qzi 閱讀(1181) 評論(0)  編輯  收藏 所屬分類: ssh2.0_2.0_3.1

          The prefix "tx" for element "tx:advice" is not bound

          這個錯誤的原因很簡單是:

          我們在定義申明AOP的時候。。沒有加載schema。

          具體表現如下:

          <beans>

           <tx:advice id="txAdvice" transaction-manager="transactionManager">  
               <tx:attributes>  
                   <tx:method name="get*" read-only="true"/>  
                   <tx:method name="*" propagation="REQUIRES_NEW" rollback-for="Exception"/>  
               </tx:attributes>  
           </tx:advice>

           <!-- aop代理設置-->  
           <aop:config proxy-target-class="true">   
          ....

           </aop:config>

          </beans>

          這時會拋出異常不認<TX>標簽。。起先還以為是沒有加載JAR包呢。。

          后來讀AOP文檔才發現<beans>中要加入“xmlns:aop”的命名申明,并在“xsi:schemaLocation”中指定aop配置的schema的地址

          配置文件如下:

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

          這些才是最關鍵的地方。。后面的配置不變。。。。


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


          網站導航:
           
          主站蜘蛛池模板: 西藏| 清原| 琼中| 迁西县| 永吉县| 长武县| 略阳县| 咸宁市| 成安县| 株洲市| 湾仔区| 巴彦县| 慈利县| 德格县| 玉屏| 通海县| 德江县| 峨眉山市| 富顺县| 阳山县| 南漳县| 鹤山市| 万年县| 嫩江县| 新晃| 高青县| 红桥区| 陆良县| 乌拉特中旗| 白朗县| 南京市| 双峰县| 鄂托克前旗| 陵水| 梅河口市| 驻马店市| 定安县| 玛沁县| 收藏| 山东省| 景德镇市|