java - 接口中定义的 Spring WebClient 端点
问题描述
我问了一个问题,如何用 Spring 替代品替换 JAXrs 客户端,但没有得到回答,但我想我现在知道用 WHAT 替换 jax 的答案,但不知道如何替换。
我决定使用 Spring 的 WebClient,因为 RestTemplate 处于维护模式,将来会被弃用。
现在知道我应该使用 WebClient - 我还有另一个问题。
如果我有一个带有注释的 Rest Endpoints 的接口,我如何将此接口与 WebClient 一起使用?或者我应该只是简单地在每个方法中分别使用 url 和 http 方法创建请求?
我有这个界面
@RequestMapping("/theResource")
public interface TheResource {
@GetMapping( value = "/test")
ResponseEntity<String> test();
我想知道是否有办法在 WebClient 中使用这些信息?
我知道我能做到
WebClient.RequestBodySpec uri = client
.method(HttpMethod.GET)
.uri("/theResource/test");
但是有没有办法只用上面提到的接口创建 WebClient 呢?
我在这里问了原始问题 Spring Alternative to JAXRSClientFactory
解决方案
推荐阅读
- css - 为什么我的 css 更改没有反映在我的浏览器中?
- python - 如何在 Python 中声明未初始化变量的类型?
- netlogo - 如何解决错误:观察者无法运行代码
- android - Mockk 模拟 Kotlin 的私有财产
- java - 比较来自两个不同父节点的两个不同子节点
- flutter - 当我期望 0.00 时,Dart 四舍五入值给出 0.0
- python - 为什么我不能将我的发行版安装到 python 的本地副本中?
- javascript - React 说我正在对未安装的组件执行状态更新,但我的组件(似乎是)已安装?
- rxjs - 单元测试 NestJS Observable Http Retry
- python - DB2:将数据结果拆分为 5000 条记录