Commit 59c38785 by Pengguohui

异常处理机制

parent 4eea2eb4
/**
* Copyright (c) 2016-2019 All rights reserved.
*
*
*
*
*/
package com.maxbox.service;
......@@ -27,7 +23,7 @@ public class DynamicDataSourceTestService {
private SysUserDao sysUserDao;
@Transactional
public void updateUser(Long id){
public void updateUser(Long id) {
SysUserEntity user = new SysUserEntity();
user.setUserId(id);
user.setMobile("13500000000");
......@@ -36,7 +32,7 @@ public class DynamicDataSourceTestService {
@Transactional
@DataSource("slave1")
public void updateUserBySlave1(Long id){
public void updateUserBySlave1(Long id) {
SysUserEntity user = new SysUserEntity();
user.setUserId(id);
user.setMobile("13500000001");
......@@ -48,10 +44,16 @@ public class DynamicDataSourceTestService {
public void updateUserBySlave2(Long id){
SysUserEntity user = new SysUserEntity();
user.setUserId(id);
user.setMobile("13500000002");
user.setMobile("1350000000551");
sysUserDao.updateById(user);
System.out.println("id5 = [" + id + "]");
// try {
//测试事物
int i = 1/0;
int i = 1 / 0;
// } catch (Exception e) {
// throw new RuntimeException("--被除数不能为0");
// System.out.println("exception"+e.getMessage());
// }
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment