admin 管理员组文章数量: 1087135
Spring Boot <= 1.3
No need to define one, Spring Boot automatically defines one for you.
(springboot1.3版本以前不需要自定义一个RestTemplate,springboot为你自动定义了一个)
Spring Boot >= 1.4
Spring Boot no longer automatically defines a RestTemplate but instead defines a RestTemplateBuilder allowing you more control over the RestTemplate that gets created. You can inject the RestTemplateBuilder as an argument in your @Bean method to create a RestTemplate:
(springboot1.4版本以后需要在启动器里自定义RestTemplate,即在启动器中加入如下代码即可在类中正常使用@Autowired进行注入)
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder){
return builder.build();
}
参考自:RestTemplate注入_danielinbiti的博客-CSDN博客_resttemplate注入
本文标签: 报错 defining Bean Configuration RestTemplate
版权声明:本文标题:服务启动报错:Consider defining a bean of type ‘.RestTemplate‘ in your configuration 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1738333747a1965458.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论