简体   繁体   English

识别 Spring WebClient 使用的 UriBuilder 实现

[英]Identifying UriBuilder implementation used by Spring WebClient

I use the below syntax to make a get call using get client.我使用以下语法使用 get 客户端进行 get 调用。 In the below example , which implementation of URIBuilder is being used and how is automatically inferenced?在下面的示例中,正在使用 URIBuilder 的哪个实现以及如何自动推断?

webclient.get().uri(uriBuilder -> uriBuilder.path("/api/person/{personId}")
    .queryParam("param1", aDouble)
    .queryParam("param2", "A string value with spaces")
    .queryParam("param3", aListOfValues)
    .queryParam("param4", null)
    .build(anInteger))

This is the webclient that I am using - WebClient这是我正在使用的网络客户端 - WebClient

You can decide which implementation is used WebClient by providing a UriBuilderFactory while building it.您可以通过在构建时提供UriBuilderFactory来决定使用WebClient的实现。

The WebClient.Builder has a uriBuilderFactory(UriBuilderFactory) method where you can provide your implementation. WebClient.Builder有一个uriBuilderFactory(UriBuilderFactory)方法,您可以在其中提供您的实现。

If you don't provide one, it currently uses DefaultUriBuilderFactory which produces UriComponentsBuilder instances.如果您不提供,它当前使用DefaultUriBuilderFactory生成UriComponentsBuilder实例。


You could always instrument your code to print uriBuilder.getClass() for confirmation.您可以随时检测您的代码以打印uriBuilder.getClass()以进行确认。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM