Hon*_*dek 7 java configuration spring spring-webclient
Spring 反应式WebClient可以使用基本 URL 构建:
import org.springframework.web.reactive.function.client.WebClient;
...
@Bean
public WebClient webClient(WebClient.Builder builder) {
return builder
.baseUrl("http://example.org")
.build();
// or alternatively a shortcut
// return WebClient.create("http://example.org");
}
Run Code Online (Sandbox Code Playgroud)
有没有办法从现有实例中检索配置的基本 URL ? WebClient
就像是:
@Autowired
private WebClient webClient;
...
String baseUrl = webClient.getBaseUrl(); // I want to know how this WebClient is configured
assertEquals("http://example.org", baseUrl);
Run Code Online (Sandbox Code Playgroud)
或者类似的东西
var configuration = webClient.getConfiguration();
String baseUrl = configuration.getBaseUrl();
assertEquals("http://example.org", baseUrl);
Run Code Online (Sandbox Code Playgroud)
据我所知,参数的处理是内部和特定于实现的。但是我不明白为什么,如果是暴露 setter 的接口(通过构建器或工厂方法参数),它也不暴露 getter。我在创建实例时没有指定实现。所以我自然会期望界面能告诉我它创造了什么价值。我看不出有任何合理的理由说明为什么此信息未在界面本身中公开。
| 归档时间: |
|
| 查看次数: |
4092 次 |
| 最近记录: |