RestTemplate 会自动释放连接吗? [英] Does RestTemplate automatically release connection?
问题描述
我正在将我的 REST
客户端模块从 HttpClient.executeMethod(method)
转移到 RestTemplate.postForLocation(uri, obj)
.使用 HttpClient
,我会明确发布方法的连接:
I am shifting my REST
client module from HttpClient.executeMethod(method)
to RestTemplate.postForLocation(uri, obj)
. With the HttpClient
, I would explicitly release the connection of the method:
deleteMethod.releaseConnection();
deleteMethod.releaseConnection();
我在 Spring
中找不到任何等效的东西 RestTemplate
.它会自动释放连接吗?我想,另一种提问方式是,在调用 RestTemplate.postForLocation
之后不做任何事情是否安全?
I cannot find anything equivalent within the Spring
RestTemplate
. Does it automatically release connections? Another way to ask would be, I suppose, is it safe to not do anything after calling the RestTemplate.postForLocation
?
推荐答案
spring 模板的目标之一是简化多余的事情.RestTemplate 也不例外,它会为您管理连接.
One of the goals of spring templates is to make easy the things that are redundant. RestTemplate is not the exception and it manage the connection for you.
你可以在这里看到更多.
You can see more here.
这篇关于RestTemplate 会自动释放连接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!