在配置tx:annotation-driven/ 一直报错…
第一个问题
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager'
available:
No matching PlatformTransactionManager bean found for qualifier 'transactionManager' - neither qualifier match nor bean name match!
出现这种报错!!!!!!
原因是没有加上:
事务核心管理器,封装了所有事务操作. 依赖于连接池
在.xml的配置文件中加入下面一段话后就解决问题
<!-- 事务核心管理器,封装了所有事务操作. 依赖于连接池 -->
<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<property name="dataSource" ref="dataSource" ></property>
</bean>
第二个问题
通配符的匹配很全面, 但无法找到元素 'tx:annotation-driven'
这种错误是xsi:schemaLocation:后面没有配置正确
我们需要将tx的schemaLocation加进去
例如:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
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 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">