spring - 为什么没有像 RestTemplate 中的 postForEntity 那样的 patchForEntity 方法?

标签 spring rest spring-boot controller resttemplate

我想知道为什么没有patchForEntity RestTemplate中提供的方法类同 postForEntitygetForEntity .只有 patchForObject方法在那里只返回对象但不返回 ResponseEntity .

获取 ResponseEntity对于 PATCH请求,我们必须使用 exchange RestTemplate的方法,这没关系,但我真的很好奇为什么 Spring 的人没有提供一个方便的 patchForEntity方法。

有什么线索吗?

最佳答案

Spring's GitHub中已经打开了一个类似的问题.引用那里给出的答案:

... While it would be technically possible to introduce a patchForEntity() method, analogous to the existing getForEntity() and postForEntity() methods, there are no plans to introduce new functionality in the RestTemplate API ...


因此,为了回答您的问题,似乎没有提供此功能的技术原因,只是这样做的优先级不够高,因为正如您在问题中提到的,您可以达到您的效果想使用 exchange方法。无论如何(这对我来说是新闻),“没有计划在 RestTemplate API 中引入新功能”,因为它将被弃用,取而代之的是 WebClient ,所以赔率是 RestTemplate 永远不会有 patchForEntity()方法。

关于spring - 为什么没有像 RestTemplate 中的 postForEntity 那样的 patchForEntity 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55323510/

相关文章:

spring-boot - 基于 Apache Camel 的 Udp 服务器

java - 避免在 Spring MVC 请求映射中使用 URI 中的 float 进行文件扩展名检测

java - 在 @DynamoDBTable 中创建 List<MyObject> 而不使用 dynamodbmarshalling 的替代方法(已弃用)

java - 具有多个帖子资源的 ReSTLet 服务

java - 将自定义依赖项添加到 spring 项目后缺少类

Visual Studio 2010 中的 Rest 初学者工具包

rest - 如何确定Rest API响应生命周期

Java EE 服务器中的 Spring Batch

Spring Boot 以及如何配置与 MongoDB 的连接详细信息?

java - Spring ROO : JUnit test fails