问题出现:springcloud架构中配置消费者服务后启动时报错
问题描述:
A component required a bean of type ‘org.springframework.web.client.RestTemplate’ that could not be found.
问题截图:
出现原因:
在 Spring Boot 1.3版本中,会默认提供一个RestTemplate的实例Bean,而在 Spring Boot 1.4以及以后的版本中,这个默认的bean不再提供了,我们需要在Application启动时,手动创建一个RestTemplate的配置。
解决方法:
在启动类中添加该实例:
@Bean
RestTemplate restTemplate(){
return new RestTemplate();
}
参考博文:相关问题具体描述