RestTemplate是否自动释放连接? [英] Does RestTemplate automatically release connection?

查看:189
本文介绍了RestTemplate是否自动释放连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的 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

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.

http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html

这篇关于RestTemplate是否自动释放连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆