【问题标题】:Error: Load balancer does not contain an instance for the service while using Spring Cloud Load Balancer错误:负载均衡器在使用 Spring Cloud Load Balancer 时不包含服务的实例
【发布时间】:2021-08-18 23:44:30
【问题描述】:

我正在尝试从功能区迁移到客户端负载均衡器并具有以下配置:

id 'org.springframework.boot' version '2.4.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
'springCloudVersion', "2020.0.2"


application.properties (library-service)
user-service.ribbon.listOfServers=http://localhost:9091


UserServiceProxy.java
@FeignClient(name="user-service") 
@LoadBalancerClient(name="user-service")
interface UserServiceProxy{}

ApplicationClass.java
@EnableFeignClients(basePackages = "com.library.service")
public class LibraryServiceApplication {}

我不明白为什么在尝试使用代理访问用户服务时出现以下错误。 谁能帮帮我?

There was an unexpected error (type=Internal Server Error, status=500). [503] during [GET] to [http://user-service/users/10] [UserServiceProxy#getUserById(Long)]: [Load balancer does not contain an instance for the service user-service]

Ask1) 我们不能在没有 Eureka 服务器的情况下使用 Client LoadBalancer 吗?正如我们在早期版本中使用的 Ribbon 和 feign。

感谢任何帮助!

【问题讨论】:

  • 负载均衡器无法识别功能区属性

标签: spring spring-boot spring-cloud spring-cloud-feign


【解决方案1】:

是的,你可以将 Spring Cloud LoadBalancer 与 Eureka 一起使用,但你不能将它与 Ribbon 特定的属性一起使用。可以看到in the docs,在这种情况下可以使用SimpleDiscoveryClient代替ribbon.listOfServers

【讨论】:

猜你喜欢
  • 2021-08-29
  • 2023-02-09
  • 2021-07-27
  • 2021-04-03
  • 2020-12-31
  • 1970-01-01
  • 2016-04-02
  • 2021-01-10
  • 2020-10-06
相关资源
最近更新 更多