我将REST客户端模块从HttpClient.executeMethod(method)转换为RestTemplate.postForLocation(uri, obj)。使用 HttpClient ,我将显式释放该方法的连接:

deleteMethod.releaseConnection();

我在Spring RestTemplate 中找不到任何等效的东西。它会自动释放连接吗?我想,另一种询问方式是在调用RestTemplate.postForLocation之后不执行任何操作是否安全?

最佳答案

Spring模板的目标之一是简化多余的事情。 RestTemplate也不例外,它为您管理连接。

您可以在这里看到更多。

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

09-05 02:23
查看更多