Posted on 2008-08-30 00:01
Qzi 閱讀(1178)
評論(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">
這些才是最關鍵的地方。。后面的配置不變。。。。