一、問題
配置spring持久層xml配置文件時,<tx:annotation-driven>
標籤裏有個transaction-manager
屬性一直紅色,很明顯有問題;
二、解決
1、只要在配置文件上加入:
xmlns:tx="
http://www.springframework.org/schema/cache"
xmlns:tx="http://www.springframework.org/schema/tx"
配置信息即可;
2、一波已平,一波又起,transaction-manager不報紅了,但是,beans又報錯了,信息如下:
說
Attribute "tx" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified for element "beans"
意思是綁定http://www.w3.org/2000/xmlns/
的tx屬性已經被beans標籤特別定義了;但是我配置的文件頭明明定義的是:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
這個東西啊?
我如果把:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
去掉,則下面引用的xsi屬性就報錯了:
現在要的問題是,有兩個相同的屬性【xmlns:tx】:
這裏,因爲下面的屬性是我需要的,上面的那個屬性,我選擇刪除
即刪除下面這句:
xmlns:tx="http://www.springframework.org/schema/cache"
然後就不報錯了;
配置文件頭的源代碼如下:
<?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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
完畢;