问题
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();
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
?
回答1:
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.
http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html
来源:https://stackoverflow.com/questions/39795236/does-resttemplate-automatically-release-connection