spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.22k stars 786 forks source link

Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer? #724

Closed rajeshhereforyou closed 2 years ago

rajeshhereforyou commented 2 years ago

``Hi,

I'm using 'org.springframework.cloud:spring-cloud-dependencies:2020.0.5' which is pulling 'org.springframework.cloud:spring-cloud-starter-openfeign:3.0.6' to consume a feign client and getting below error.

Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

As per my understanding of the below thread, this should be fixed in 2.2.8.RELEASE but still seeing the same issue and not sure what's the root cause of this issue. Please suggest.

https://github.com/spring-cloud/spring-cloud-openfeign/issues/517

Here is the sample code of my app, which is consuming the feign client

@EnableFeignClients(basePackages = {"my.feignclient.package"})
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

and here is my feign client

@FeignClient(value = "abc", contextId = "MyApiClient")
public interface MyApiClient extends MyApi {
}
OlgaMaciaszek commented 2 years ago

Hello @rajeshhereforyou , you need to add spring-cloud-starter-loadbalancer dependency to your pom.

spring-cloud-issues commented 2 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues commented 2 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

agitrubard commented 1 year ago

Hello @rajeshhereforyou , you need to add spring-cloud-starter-loadbalancer dependency to your pom.

The solution is working, thank you very much 🙌🏼

It worked after adding the following dependency to the pom.xml file ✅

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>