没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论














spring 的 annotation-driven 配置事务管理器详解 (多数据源配置
假定 spring容器中定义了两个事务管理器:transactionManagerX,transactionManagerY,分管两个数据源
datasourceY.
<tx:annotation-driventransaction-manager="transactionManagerX"/>
<tx:annotation-driventransaction-manager="transactionManagerY"/>
(spring 容器中的定义顺序如上)
有如下应用代码:
publicinterfaceTestEntityService{
publicvoidmethodX();
publicvoidmethodY();
}
接口实现类 1
publicclassTestEntityServiceImplimplementsTestEntityService{
@Resource
privateTestEntityDaotestEntityDao;//实际操作的是 datasourceX.
@Transactional
publicvoidmethodX(){
testEntityDao.xxx();
testEntityDao.zzz();
}
publicvoidmethodY(){
}
}
接口实现类 2
publicclassAnotherTestEntityServiceImplimplementsTestEntityService{
@Resource
privateTestEntityDaoanOtherTestEntityDao;//实际操作的是 datasourceY.
@Transactional
publicvoidmethodX(){
testEntityDao.mmm();
testEntityDao.nnn();
}
publicvoidmethodY(){
}
}
假设方法 methodX 需要事务控制的,通常我们是直接在方法上添加@Transactional 标注,
但是好像 spring3.0(具体版本没弄清)之前的 Transactional 标注不支持区分使用哪个事务管理器。3.0 之后的版本
个 string 类型的 value 属性来特殊指定加以区分。
例如@Transactional("aaaaa"),即显示的要求 spring 用 id="aaaaa"的事务管理器来管理事务。该属性亦可省略(省略的话用容器中缺省的
transactionManager)
对于该属性的用法做了如下测试来
资源评论

- 北风神2016-01-20很好的文档,下载保存了

teddy9393
- 粉丝: 4
- 资源: 15
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
