Skip to content

Commit 1c49ad6

Browse files
committed
optimize doc
1 parent 4a0decd commit 1c49ad6

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Of course, in an extremely high concurrent scenario, the parallel call interface
1515

1616
## Instruction
1717

18+
pom.xml
19+
1820
```xml
1921
<dependency>
2022
<groupId>io.github.lvyahui8</groupId>
@@ -23,6 +25,13 @@ Of course, in an extremely high concurrent scenario, the parallel call interface
2325
</dependency>
2426
```
2527

28+
application.properties
29+
30+
```
31+
# 指定要扫描注解的包
32+
io.github.lvyahui8.spring.base-packpages=io.github.lvyahui8.spring.example
33+
```
34+
2635
- `@DataProvider`: define the data provider
2736
- `@DataConsumer`: define the method parameter dependency type as return the value of other interfaces, the other interface is a @DataProvider
2837
- `@InvokeParameter`: define the method parameter dependency type as the user input value
@@ -44,18 +53,18 @@ require input parameter `userId`.
4453

4554
```java
4655
@Service
47-
Public class PostServiceImpl implements PostService {
56+
public class PostServiceImpl implements PostService {
4857
    @DataProvider(id = "posts")
4958
    @Override
50-
    Public List<Post> getPosts(@InvokeParameter("userId") Long userId) {
51-
        Try {
59+
    public List<Post> getPosts(@InvokeParameter("userId") Long userId) {
60+
        try {
5261
            Thread.sleep(1000L);
5362
        } catch (InterruptedException e) {
5463
        }
5564
        Post post = new Post();
5665
        post.setTitle("spring data aggregate example");
5766
        post.setContent("No active profile set, falling back to default profiles");
58-
        Return Collections.singletonList(post);
67+
        return Collections.singletonList(post);
5968
    }
6069
}
6170
```
@@ -66,13 +75,13 @@ require input parameter `userId`.
6675

6776
```java
6877
@Service
69-
Public class UserServiceImpl implements UserService {
78+
public class UserServiceImpl implements UserService {
7079

7180
    @DataProvider(id = "user")
7281
    @Override
73-
    Public User get(@InvokeParameter("userId") Long id) {
82+
    public User get(@InvokeParameter("userId") Long id) {
7483
        /* */
75-
        Try {
84+
        try {
7685
            Thread.sleep(100L);
7786
        } catch (InterruptedException e) {
7887
        }
@@ -81,7 +90,7 @@ Public class UserServiceImpl implements UserService {
8190
        user.setId(id);
8291
        user.setEmail("[email protected]");
8392
        user.setUsername("lvyahui8");
84-
        Return user;
93+
        return user;
8594
    }
8695
}
8796
```
@@ -92,13 +101,13 @@ Combine `@DataProvider` ( `@DataConsumer` \ `@InvokeParameter` ) to achieve ag
92101

93102
```java
94103
@Component
95-
Public class UserAggregate {
104+
public class UserAggregate {
96105
    @DataProvider(id="userWithPosts")
97-
    Public User userWithPosts(
106+
    public User userWithPosts(
98107
            @DataConsumer(id = "user") User user,
99108
            @DataConsumer(id = "posts") List<Post> posts) {
100109
        user.setPosts(posts);
101-
        Return user;
110+
        return user;
102111
    }
103112
}
104113
```

README_CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
## 使用方法
1717

18+
pom.xml
19+
1820
```xml
1921
<dependency>
2022
<groupId>io.github.lvyahui8</groupId>
@@ -23,6 +25,13 @@
2325
</dependency>
2426
```
2527

28+
application.properties
29+
30+
```
31+
# Specify the package to scan the annotations
32+
io.github.lvyahui8.spring.base-packpages=io.github.lvyahui8.spring.example
33+
```
34+
2635
- `@DataProvider` 定义数据提供者
2736
- `@DataConsumer` 定义方法参数依赖类型为其他接口返回值, 其他接口是一个`@DataProvider`
2837
- `@InvokeParameter` 定义方法参数依赖类型为用户输入值

0 commit comments

Comments
 (0)