一、问题
配置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">
完毕;