前一篇文章中我们讲了SpringBoot4.0中声明式HTTP远程调用客户端的基本使用,本文我们继续来补充下使用过程中的一些细节,包括:
- 超时设置
- 异常处理
- 拦截器设置
- 底层实现细节
超时设置
- 全局超时
yml
spring:
http:
serviceclient:
goods:
base-url: "http://localhost:8082"
clients:
connect-timeout: 3s
read-timeout: 5s
- 单个客户端超时
yml
spring:
http:
serviceclient:
goods:
base-url: "http://localhost:8082"
connect-timeout: 3s
read-timeout: 8s
单个客户端超时配置的优先级更高,超时客户端会抛出ResourceAccessException异常。
点击查看完整内容:SpringBoot4.0新特性-声明式Rest客户端进阶