java.lang.IllegalStateException: No instances available for 的一种解决思路

本文详细解析了在使用SpringCloud2.2.5版本时遇到的微服务调用失败问题,主要原因是调用端未能正确获取服务列表。通过调整application.yml配置文件中的eureka.client.fetchRegistry参数为true,成功解决了服务发现的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 最近使用了SpringCloud2.2.5版本的,调用微服务,总是报一下错误。网上找了各种文章都没有解决问题。

我分析了一下原因,主要是调用端没有找到服务列表,如下。动态服务列表是空的。

c.n.l.DynamicServerListLoadBalancer      : Using serverListUpdater PollingServerListUpdater
2020-02-21 10:18:08.278  INFO 11688 --- [io-19603-exec-1] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client CRUDER initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=CRUDER,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@1030a86f
2020-02-21 10:18:08.310 ERROR 11688 --- [io-19603-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: No instances available for CRUDER] with root cause

java.lang.IllegalStateException: No instances available for

 

经过探索,发现问题出在了一下部分。在配置文件application.yml文件中:

eureka:  
  instance:  
    hostname: localhost  
  client:  
    registerWithEureka: true  
    fetchRegistry: false
    serviceUrl:  
      defaultZone: http://${eureka.instance.hostname}:9871/eureka/

红色部位改为true,就可以了。

好了祝大家鼠年好运

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值