我正在尝试使用Java中的Apache HTTPClient为REST Web服务创建用于构建框架的HTTPClient。
在这里,我发现我们可以使用以下两种方式创建客户端。我想知道它们之间的区别。
1.HTTPCLientBuilder.create()。建立()
2.HTTPClients.custom()。build()
答案 0 :(得分:0)
答案是关于SO,只是有点隐藏。从这个question:
重新发出幸福感99的答案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
任何自定义的东西时,显然没有差异