How to use HttpComponentsClientHttpRequestFactory with RestTemplate efficiently?

北城余情 提交于 2019-12-06 11:11:06

In one of my projects, I had created a static instance of HttpComponentsClientHttpRequestFactory and passed it to every RestTemplate. Though, in here, it is suggested to also have a global instance of RestTemplate.

Maybe irrelevant, but one important point is to pass HttpClients.createDefault() to your HttpComponentsClientHttpRequestFactory while constructing it since by default, this factory uses system properties to create HttpClient for your factory and that may cause a lot of pain in production environment. You may also pass your custom HttpClient.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!