[英]Spring configuration and transaction
我玩了無數次,更改了默認的目標名稱空間,但仍然會抱怨上下文未聲明的元素: Multiple annotations found at this line: - cvc-elt.1: Cannot find the declaration of element
'context:annotation-driven'的聲明。
------Configuration File----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<context:annotation-driven/>
<tx:annotation-driven/>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>/WEB-INF/classes/hibernate.cfg.xml</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
...
另外,由於事務不起作用,我添加了兩個注釋驅動的文件, tx:annotation-driven
使用了擁有休眠狀態的會話的transactionManager
?
我通過hibernate3使用了派生的sessionFactory,因此在該方法運行更新查詢之前只需要一個事務即可。
謝謝!
嘗試添加<?xml version="1.0" encoding="UTF-8"?>
並更好地使用基於Java的配置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.