出现错误:OpenFeign 启动失败:No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer

SpringBoot与SpringCloud对应版本关系

错误信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-07 10:13:30.879 ERROR 29932 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memberController': Unsatisfied dependency expressed through field 'couponFeignService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'io.gitee.taopanfeng.member.feign.CouponFeignService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643) ~[spring-beans-5.3.2.jar:5.3.2]
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'io.gitee.taopanfeng.member.feign.CouponFeignService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:176) ~[spring-beans-5.3.2.jar:5.3.2]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101) ~[spring-beans-5.3.2.jar:5.3.2]
...
Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?
at org.springframework.cloud.openfeign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:309) ~[spring-cloud-openfeign-core-3.0.0.jar:3.0.0]
...


Process finished with exit code 1

SpringCloud 版本问题

SpringBoot与SpringCloud对应版本关系

明明是 SpringBoot 2.4.1 对应 SpringCloud 2020.0.0 的呀,但还是出错~,只能降低版本来解决了~

解决方式

在这里插入图片描述