关于Pre-bound JDBC Connection found! HibernateTransactionManager does not 异常小结

昨天帮女朋友配置ssh框架的多数据源, 本以为对此已经很熟悉,配置完其他的错倒是还能接受,调了一下就好了。  唯独 Pre-bound JDBC Connection found! HibernateTransactionManager does not  这个异常着实浪费了我些时间。

也百度看到网上说是, 因为在代码中同时使用了jdbc和spring管理的hibernate 两种事务导致的,所以一开始重心放到了代码中,可是检查了N次代码没有问题啊, 最后实在不行找一个配置好的开始比对,试了几次才发现原来是配置事务的xml文件的头部不对,替换下面这个就好了。    原因:之前的配置少了schema/tx.xsd 和schma/tx/spring-tx.xsd和 schema/aop/spring-aop.xsd  来声明使用的事务。  这里记录一下希望可以帮到有同样异常的小伙伴。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans"
       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"
>
原文地址:https://www.cnblogs.com/qiaoyutao/p/10978438.html