我正在尝试创建HTTPClient,以使用Java for REST Web服务中的Apache HTTPClient构建框架。
在这里,我发现我们可以使用以下两种方式创建客户端。我想知道它们之间的区别。
1. HTTPCLientBuilder.create()。build()
2. HTTPClients.custom()。build()
最佳答案
答案就这样,只是有点隐藏。从此question重新发布euphoria99的答案:
HttpClient (interface)
implemented by:
CloseableHttpClient - ThreadSafe.
DefaultHttpClient - ThreadSafe BUT deprecated, use HttpClientBuilder instead.
HttpClientBuilder - NOT ThreadSafe, BUT creates ThreadSafe CloseableHttpClient.
Use to create CUSTOM CloseableHttpClient.
HttpClients - NOT ThreadSafe, BUT creates ThreadSafe CloseableHttpClient.
Use to create DEFAULT or MINIMAL CloseableHttpClient.
因此,当您编写
.custom()
然后不set
进行任何自定义操作时,显然没有区别关于apache-httpclient-4.x - 使用HTTPClientBuilder.create()。build()与HTTPClient.custom()。build()有什么区别,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45744159/