@@ -15,6 +15,8 @@ Of course, in an extremely high concurrent scenario, the parallel call interface
15
15
16
16
## Instruction
17
17
18
+ pom.xml
19
+
18
20
``` xml
19
21
<dependency >
20
22
<groupId >io.github.lvyahui8</groupId >
@@ -23,6 +25,13 @@ Of course, in an extremely high concurrent scenario, the parallel call interface
23
25
</dependency >
24
26
```
25
27
28
+ application.properties
29
+
30
+ ```
31
+ # 指定要扫描注解的包
32
+ io.github.lvyahui8.spring.base-packpages=io.github.lvyahui8.spring.example
33
+ ```
34
+
26
35
- ` @DataProvider ` : define the data provider
27
36
- ` @DataConsumer ` : define the method parameter dependency type as return the value of other interfaces, the other interface is a @DataProvider
28
37
- ` @InvokeParameter ` : define the method parameter dependency type as the user input value
@@ -44,18 +53,18 @@ require input parameter `userId`.
44
53
45
54
``` java
46
55
@Service
47
- Public class PostServiceImpl implements PostService {
56
+ public class PostServiceImpl implements PostService {
48
57
@DataProvider (id = " posts" )
49
58
@Override
50
- Public List<Post > getPosts (@InvokeParameter (" userId" ) Long userId ) {
51
- Try {
59
+ public List<Post > getPosts (@InvokeParameter (" userId" ) Long userId ) {
60
+ try {
52
61
Thread . sleep(1000L );
53
62
} catch (InterruptedException e) {
54
63
}
55
64
Post post = new Post ();
56
65
post. setTitle(" spring data aggregate example" );
57
66
post. setContent(" No active profile set, falling back to default profiles" );
58
- Return Collections . singletonList(post);
67
+ return Collections . singletonList(post);
59
68
}
60
69
}
61
70
```
@@ -66,13 +75,13 @@ require input parameter `userId`.
66
75
67
76
``` java
68
77
@Service
69
- Public class UserServiceImpl implements UserService {
78
+ public class UserServiceImpl implements UserService {
70
79
71
80
@DataProvider (id = " user" )
72
81
@Override
73
- Public User get (@InvokeParameter (" userId" ) Long id ) {
82
+ public User get (@InvokeParameter (" userId" ) Long id ) {
74
83
/* */
75
- Try {
84
+ try {
76
85
Thread . sleep(100L );
77
86
} catch (InterruptedException e) {
78
87
}
@@ -81,7 +90,7 @@ Public class UserServiceImpl implements UserService {
81
90
user. setId(id);
82
91
user
. setEmail(
" [email protected] " );
83
92
user. setUsername(" lvyahui8" );
84
- Return user;
93
+ return user;
85
94
}
86
95
}
87
96
```
@@ -92,13 +101,13 @@ Combine `@DataProvider` ( `@DataConsumer` \ `@InvokeParameter` ) to achieve ag
92
101
93
102
``` java
94
103
@Component
95
- Public class UserAggregate {
104
+ public class UserAggregate {
96
105
@DataProvider (id = " userWithPosts" )
97
- Public User userWithPosts (
106
+ public User userWithPosts (
98
107
@DataConsumer (id = " user" ) User user ,
99
108
@DataConsumer (id = " posts" ) List<Post > posts ) {
100
109
user. setPosts(posts);
101
- Return user;
110
+ return user;
102
111
}
103
112
}
104
113
```
0 commit comments