访问接口错误,com.netflix.client.ClientException: Load balancer does not have available server for client:

使用openFeign、loadbalancer和netflix-hystrix进行远程调用与熔断

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    <version>2.2.10.RELEASE</version>
</dependency>

版本问题:

<!-- spring boot 依赖 -->
 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-dependencies</artifactId>
     <version>2.7.6</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

 <!-- spring cloud 依赖 -->
 <dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-dependencies</artifactId>
     <version>2021.0.5</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

 <!-- spring cloud alibaba 依赖 -->
 <dependency>
     <groupId>com.alibaba.cloud</groupId>
     <artifactId>spring-cloud-alibaba-dependencies</artifactId>
     <version>2021.0.1.0</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

<!--openfeign-->
<dependency>
 	<groupId>org.springframework.cloud</groupId>
  	<artifactId>spring-cloud-starter-openfeign</artifactId>
  	 <version>3.1.5</version>
</dependency>

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  <version>2.2.10.RELEASE</version>
</dependency>


application.yml配置

#开启熔断支持
feign:
  circuitbreaker:
    enabled: true    #开启服务降级

<!-- spring boot 依赖 -->
 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-dependencies</artifactId>
     <version>2.1.8.RELEASE</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

 <!-- spring cloud 依赖 -->
 <dependency>
     <groupId>org.springframework.cloud</groupId>
     <artifactId>spring-cloud-dependencies</artifactId>
     <version>Greenwich.SR3</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

 <!-- spring cloud alibaba 依赖 -->
 <dependency>
     <groupId>com.alibaba.cloud</groupId>
     <artifactId>spring-cloud-alibaba-dependencies</artifactId>
     <version>2.1.0.RELEASE


----------


</version>
     <type>pom</type>
     <scope>import</scope>
 </dependency>

<!--openfeign-->
<dependency>
 	<groupId>org.springframework.cloud</groupId>
  	<artifactId>spring-cloud-starter-openfeign</artifactId>
  	 <version>2.1.3.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  <version>2.1.3.RELEASE</version>
</dependency>


application.yml配置

#开启熔断支持
feign:
  hystrix:
    enabled: true    #开启服务降级

远程调用的api
访问接口错误,com.netflix.client.ClientException: Load balancer does not have available server for client:_第1张图片
熔断机制
访问接口错误,com.netflix.client.ClientException: Load balancer does not have available server for client:_第2张图片

你可能感兴趣的:(spring,boot)