【Java】spring事务控制配置报错,application-persstence.xml文件中transaction-manager报红

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

完毕;
————————————————
版权声明:本文为CSDN博主「张牧野菌」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/River_Continent/article/details/88871839

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值