使用@EnableFeignClients报错
首先列出错误
-02-22 20:55:05.693 ERROR 54958 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:Field userClient in com.aohan.service_consumer.controller.UserController required a bean of type 'com.aohan.service_consumer.client.UserClient' 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 'com.aohan.service_consumer.client.UserClient' in your configuration.
经过误打误撞解决错误
@EnableFeignClients
这个注解只能添加到主启动类上
而不能通过以下方式进行添加
@Configuration@EnableFeignClientspublic class FeignConfig {}
解决方案
将@EnableFeignClients
注解添加到主启动类解决
@SpringCloudApplication@EnableFeignClients //开启feignpublic class ServiceConsumerApplication {public static void main(String[] args) {SpringApplication.run(ServiceConsumerApplication.class, args);}}