Springs RestTemplate default connection pool

前端 未结 4 1734
轮回少年
轮回少年 2020-12-24 13:12

Just wondering if RestTemplate out of the box uses connection pooling or does it simply establish a new connection each time ?

4条回答
  •  离开以前
    2020-12-24 13:51

    By default RestTemplate creates new Httpconnection every time and closes the connection once done.

    If you need to have a connection pooling under rest template then you may use different implementation of the ClientHttpRequestFactory that pools the connections.

    new RestTemplate(new HttpComponentsClientHttpRequestFactory())
    

提交回复
热议问题