spring配置事務 元素 "tx:annotation-driven" 的前綴 "tx" 未綁定


轉自:https://blog.csdn.net/u013310119/article/details/80669338

在進行spring與mybatis整合時,啟動項目報錯,控制台提示“元素 "tx:annotation-driven" 的前綴 "tx" 未綁定”。

經過查找,是因為沒有在該配置文件中定義tx開頭的命名空間。

配置文件spring-mybatis.xml中需要添加以下紅色字體部分:

<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:context="http://www.springframework.org/schema/context"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd    
                        http://www.springframework.org/schema/context    
                        http://www.springframework.org/schema/context/spring-context-3.1.xsd    
                        http://www.springframework.org/schema/mvc    
                        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
"> 

上面的問題便可以解決。

同理,如果報出 “元素 'aop' 未綁定,前綴 'tx' 未綁定,前綴 'mvc' 未綁定”等,也可用以上方法解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM