ShardingSphere-事务管理
<dependencies>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-transaction-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
@Service
public class UserService implements IUserServer{
@Autowired
private UserDao userDao;
* 新增操作
* @ShardingTransactionType注解添加事务管理
* @param record 记录
* @return int
*/
@Transactional(rollbackFor = Exception.class)
@ShardingTransactionType(TransactionType.XA)
@Override
public int insert(UserModel record) {
return userDao.insert(record);
}
}