To resolve the error "java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-netflix-ribbon?" you can follow these steps:
- Check if you have included the
spring-cloud-starter-netflix-ribbon
dependency in your project. This dependency provides the necessary Feign client for load balancing. - If you are using Maven, ensure that the dependency is added to your
pom.xml
file:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>{version}</version>
</dependency>
If you are using Gradle, add the following dependency to your build.gradle
file:
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-ribbon:{version}'
Ensure that you replace {version}
with the version of Spring Cloud you are using.
Replacing path
with url
in the Feign client class, along with @ImportAutoConfiguration({FeignAutoConfiguration.class})
in the main class, may work.
Please share your pom.xml
. It appears that you don't have the spring-cloud-starter-loadbalancer
dependency in your project.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>2.4.4</version>
</dependency>
Change the FeignClient
class to:
@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
public class FeignClientApplication {
public static void main(String[] args) {
SpringApplication.run(FeignClient.class, args);
}
}
The following Maven dependency helped me solve this issue:
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form</artifactId>
<version>3.4.1</version>
</dependency>
Read Similar Articles
- Download sample nested json for testing
- [Fixed] : Could not load file or assembly 'office, Version=15.0.0.0 Using Microsoft.Office.Interop.Excel
- How to access dbcontext in signalr hub in asp net core example
- Fixed Error: "avdmanager is missing from the Android SDK" issue in VS Code
- [Solved]-How To Call Rest API From Excel Macros VBA And Parse Json
- Implementing “Remember Me” Feature In ASP.NET MVC