Skip to content

Commit c0ce303

Browse files
authored
Update README.md
1 parent f05a9d4 commit c0ce303

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ key=ip+url+args
5353

5454
```yaml
5555
spring:
56-
redis:
57-
host: 127.0.0.1
58-
port: 6379
56+
data:
57+
redis:
58+
host: 127.0.0.1
59+
port: 6379
5960
```
6061
6162
理论是支持 [redisson-spring-boot-starter](https://github.com/redisson/redisson/tree/master/redisson-spring-boot-starter) 全部配置
@@ -105,6 +106,19 @@ String info() default "重复请求,请稍后重试";
105106
```java
106107
boolean delKey() default false;
107108
```
109+
- 6. 全局异常处理:当幂等性触发后,切面会抛出 IdempotentException 异常。需要在全局异常处理器中捕获此异常并处理,返回合适的错误信息。
110+
111+
```java
112+
@ControllerAdvice
113+
public class GlobalExceptionHandler {
114+
115+
@ExceptionHandler(IdempotentException.class)
116+
public ResponseEntity<String> handleIdempotentException(IdempotentException ex) {
117+
// 处理幂等异常,返回自定义的错误信息或业务逻辑
118+
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ex.getMessage());
119+
}
120+
}
121+
```
108122

109123
#### 微信群
110124

0 commit comments

Comments
 (0)