当需要使用服务间的互相调用的时候,通常来说最优雅的方式莫过于Feign调用了.但是有时候特殊原因还是需要使用httpClient之类的工具. 本次我在使用RestTemplate调用本地服务的时候,会出现如下错误: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.
配置类: @Configuration public class FeignConfiguration { @Bean(name="remoteRestTemplate") public RestTemplate RestTemplate(){ SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setConnectTimeout(500
目录 1. RestTemplate简单使用 2. 一些其他设置 3. 简单总结 在项目中,当我们需要远程调用一个HTTP接口时,我们经常会用到RestTemplate这个类.这个类是Spring框架提供的一个工具类.Spring官网对它的介绍如下: RestTemplate: The original Spring REST client with a synchronous, template method API. 从上面的介绍中我们可以知道:RestTemplate是一个同步的Rest