几天前我发布了下面的错误,并且有几个回复。有人建议,当响应是传输编码类型分块时,会出现错误。我该怎么做才能告诉服务器不要分块或修复我的末端,以便 ReadTemplate 能够正常工作。而且,顺便说一句,我从 WeatherUndergound 的 REST 服务中阅读,如果知道这有用的话。
Could not extract response: no suitable HttpMessageConverter found for
response type [net.cheshiresgrin.currentConditions.Display] and
content type [application/json;charset=UTF-8]
最佳答案
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
并在 pom 文件中添加 Maven 依赖项
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${com.fasterxml.jackson.version}</version>
</dependency>
关于java - 如何使用 Spring RestTemplate 处理传输编码分块 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30064461/