Spring 为什么不像RestTemplate中的postForEntity那样没有patchForEntity方法?
我想知道为什么在Spring 为什么不像RestTemplate中的postForEntity那样没有patchForEntity方法?,spring,rest,spring-boot,controller,resttemplate,Spring,Rest,Spring Boot,Controller,Resttemplate,我想知道为什么在restemplate类中没有提供与postForEntity和getForEntity相同的patchForEntity方法。只有patchForObject方法,它只返回对象,而不返回ResponseEntity 要获得补丁请求的响应,我们必须使用restemplate的交换方法,这是可以的,但我真的很好奇为什么Spring的家伙没有提供一个方便的补丁实体方法 有什么线索吗?一个类似的问题已经在中国公开。引用上面给出的答案: 。。。虽然在技术上可以引入一个patchForEn
restemplate
类中没有提供与postForEntity
和getForEntity
相同的patchForEntity
方法。只有patchForObject
方法,它只返回对象,而不返回ResponseEntity
要获得补丁
请求的响应
,我们必须使用restemplate
的交换
方法,这是可以的,但我真的很好奇为什么Spring的家伙没有提供一个方便的补丁实体
方法
有什么线索吗?一个类似的问题已经在中国公开。引用上面给出的答案: 。。。虽然在技术上可以引入一个
patchForEntity()
方法,类似于现有的getForEntity()
和postforeEntity()
方法,但没有计划在RestTemplate
API中引入新功能
因此,为了回答您的问题,似乎没有技术上的理由不提供此功能,只是这样做的优先级不够高,因为正如您在问题中提到的,您可以使用exchange
方法实现您想要的效果。无论如何(这对我来说是新闻),“没有计划在RestTemplateAPI中引入新功能”,因为它将被弃用,取而代之的是WebClient
,所以RestTemplate
可能永远不会有patchForEntity()
方法