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">

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


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


          網站導航:
           
          主站蜘蛛池模板: 千阳县| 阿图什市| 布拖县| 运城市| 饶阳县| 若尔盖县| 玉山县| 新兴县| 城市| 辛集市| 漠河县| 盘锦市| 嵊泗县| 徐闻县| 治县。| 宁强县| 南溪县| 新宁县| 新蔡县| 开封市| 长岭县| 铜山县| 廊坊市| 福泉市| 苏州市| 华宁县| 南昌县| 吴堡县| 泰州市| 革吉县| 吉水县| 宁南县| 抚宁县| 福清市| 崇左市| 湟源县| 三都| 乳源| 邯郸市| 元朗区| 天气|