700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Field userClient in com.xxx.UserController required a bean of type“com.xxx“that could not be found.

Field userClient in com.xxx.UserController required a bean of type“com.xxx“that could not be found.

时间:2022-07-04 23:16:29

相关推荐

Field userClient in com.xxx.UserController required a bean of type“com.xxx“that could not be found.

使用@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);}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。