---
title: "springcloud分布式服务脏读死锁解决方案"
author: "coffeehot"
date: "2017-08-23T11:33:08Z"
tags: []
categories: ["企业架构"]
slug: "springcloud"
draft: false
lastmod: "2017-08-23T11:33:08Z"
id: 2390784
url: "https://coffeehot.iteye.com/blog/2390784"
---

解决springcloud分布式服务脏读死锁等异常

查询更新同一张表时，需要采用select...for update进行行级锁

```
//设置事务传播特性及隔离级别
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackFor = {Throwable.class})
```

```
select
<include refid="Base_Column_List" />
from t_account_detail t
where t.user_id = #{userId}
for update;
```