解决:No qualifying bean of type ‘org.springframework.web.client.RestTemplate‘ available:

SpringBoot 项目启动时报错:

 No qualifying bean of type ‘org.springframework.web.client.RestTemplate’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

 产生原因:由于springboot版本问题,当前项目的版本需要交给spring容器管理。

问题解决:

在项目启动类中加入以下代码:

    @Bean

    public RestTemplate restTemplate(RestTemplateBuilder builder) {

        return builder.build();

    }

    

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/b1b5d10ded.html