我已阅读 spring 文档 https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-concurrency-model当客户端和服务器使用reactor netty时,事件循环资源是共享的,这意味着当我创建多个webclient实例时,事件循环资源也是共享的? 如果我想通过代码与不同的 API 进行通信,我应该创建多个 Webclient 实例还是应该共享同一个实例?
最佳答案
由于 WebClient 实例是不可变的,因此您没有其他选择,只能使用其内置构建器为不同 API 的不同 WebClient 创建。
您可以使用 mutate() 方法复制现有的 WebClient 配置或创建一个裸露的新实例。
另请参阅https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/web-reactive.html#webflux-client和 Right way to use Spring WebClient in multi-thread environment
关于java - Spring webclient,有多少个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53197085/