admin管理员组

文章数量:1794759

学习记录报错Consider defining a bean of type ‘org.springframework.web.client.RestTemplate‘ in your configu

学习记录报错Consider defining a bean of type ‘org.springframework.web.client.RestTemplate‘ in your configu

springboot启动就报错

信如下

Field restTemplate in com.atguigu.springcloud.controller.OrderController required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found.

The injection point has the following annotations:     - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration.

 

我的代码

@Configurable public class ApplicationContextConfig{ @Bean public RestTemplate restTemplate() { return new RestTemplate(); } }

注解错误导致

@Configurable

换成

@Configuration

再次启动ok

该问题比较蠢,记录下来避免再犯

本文标签: 报错beantypeorgdefining