Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fast
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pengguohui
fast
Commits
59c38785
Commit
59c38785
authored
Apr 28, 2019
by
Pengguohui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常处理机制
parent
4eea2eb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
src/test/java/com/maxbox/service/DynamicDataSourceTestService.java
+11
-10
No files found.
src/test/java/com/maxbox/service/DynamicDataSourceTestService.java
View file @
59c38785
/**
/**
* Copyright (c) 2016-2019 All rights reserved.
* Copyright (c) 2016-2019 All rights reserved.
*
*
*
*
*/
*/
package
com
.
maxbox
.
service
;
package
com
.
maxbox
.
service
;
...
@@ -27,7 +23,7 @@ public class DynamicDataSourceTestService {
...
@@ -27,7 +23,7 @@ public class DynamicDataSourceTestService {
private
SysUserDao
sysUserDao
;
private
SysUserDao
sysUserDao
;
@Transactional
@Transactional
public
void
updateUser
(
Long
id
){
public
void
updateUser
(
Long
id
)
{
SysUserEntity
user
=
new
SysUserEntity
();
SysUserEntity
user
=
new
SysUserEntity
();
user
.
setUserId
(
id
);
user
.
setUserId
(
id
);
user
.
setMobile
(
"13500000000"
);
user
.
setMobile
(
"13500000000"
);
...
@@ -36,7 +32,7 @@ public class DynamicDataSourceTestService {
...
@@ -36,7 +32,7 @@ public class DynamicDataSourceTestService {
@Transactional
@Transactional
@DataSource
(
"slave1"
)
@DataSource
(
"slave1"
)
public
void
updateUserBySlave1
(
Long
id
){
public
void
updateUserBySlave1
(
Long
id
)
{
SysUserEntity
user
=
new
SysUserEntity
();
SysUserEntity
user
=
new
SysUserEntity
();
user
.
setUserId
(
id
);
user
.
setUserId
(
id
);
user
.
setMobile
(
"13500000001"
);
user
.
setMobile
(
"13500000001"
);
...
@@ -48,10 +44,16 @@ public class DynamicDataSourceTestService {
...
@@ -48,10 +44,16 @@ public class DynamicDataSourceTestService {
public
void
updateUserBySlave2
(
Long
id
){
public
void
updateUserBySlave2
(
Long
id
){
SysUserEntity
user
=
new
SysUserEntity
();
SysUserEntity
user
=
new
SysUserEntity
();
user
.
setUserId
(
id
);
user
.
setUserId
(
id
);
user
.
setMobile
(
"1350000000
2
"
);
user
.
setMobile
(
"1350000000
551
"
);
sysUserDao
.
updateById
(
user
);
sysUserDao
.
updateById
(
user
);
System
.
out
.
println
(
"id5 = ["
+
id
+
"]"
);
// try {
//测试事物
int
i
=
1
/
0
;
// } catch (Exception e) {
// throw new RuntimeException("--被除数不能为0");
// System.out.println("exception"+e.getMessage());
// }
//测试事物
int
i
=
1
/
0
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment