Chinaunix首页 | 论坛 | 博客
  • 博客访问: 838857
  • 博文数量: 182
  • 博客积分: 1992
  • 博客等级: 上尉
  • 技术积分: 1766
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-18 11:49
文章分类

全部博文(182)

文章存档

2019年(1)

2016年(5)

2015年(29)

2014年(38)

2013年(21)

2012年(36)

2011年(52)

我的朋友

分类: Java

2015-04-21 16:09:52

先说一下我的目录结构
1、maven项目;
2、spring applicationContext.xml放在resources目录下
3、transactionManager datasource定义在applicationContext.xml中,在web.xml中org.springframework.web.context.ContextLoaderListener加载
4、spring-mvc-servlet.xml中只定义了与web controller,json转换的bean;
问题:
service中dao1 dao2执行不回滚。

原因:
不知道,DataSourceTransactionManager是对datasource级进行事物的。

解决:
applicationContext.xml中的transactionManager datasource都放到spring-mvc-servlet.xml中,回滚了。

2015年8月3日18:56:33
找到原因了:
由于在applicationContext.xml与spring-mvc-servlet.xml都对dao与service包进行了component-scan,相当于两次,所以spring-mvc-servlet.xml最好只放与web相关的bean

阅读(18943) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~