spring2.5配置声明式事务管理需小心!!

今天没事把原来项目里的spring换成了spring2.5,这下可好,项目出大漏子了
花点时间解决了,老鸟就不要看了,主要给新手提个醒~~~

第一个就是引入命名空间的那段配置不同了

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
[color=red]http://www.springframework.org/schema/aop[/color]
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
[color=red]http://www.springframework.org/schema/tx[/color]
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

注意红色部分,少了就是不行~~~~~~~~~,这个郁闷了好久
第二个就是注意配置TransactionManager这个bean,如果是jdbc方式的话

<bean id="txManage2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>

就ok了,不过你整合和hibernate的话,可要小心了,如果你还是按照上面这个配置的话呢
像readOnly这样的属性会依然起效,但是,这也是最麻痹人的地方,[color=red]这样直接就导致了异常
不回滚!!![/color]
所以,有了hibernate之后应该使用

<bean id="txManage" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

这样的话,一切又和谐了~~~
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值