Load balancer does not have available server for client问题,是因为消费端没有调用成功服务端。下面四步是必备的,可以检查一番。
1.写nacos发现的启动类注解。
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class MeetingConsumerApplication {
}
2.在两端yml文件中配置nacos地址。
server:
port: 8002
spring:
application:
name: meeting-consumer
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
3.写openfeign的接口。
@Service
@FeignClient(value = "meeting-producer")
public interface FeignService {
@RequestMapping("/findInfo")
public Personinfo findInfo();
}
4.开启服务端的endpoint。
management:
endpoint:
web:
exposure:
include:'*'
当遇到LoadBalancer无法为客户端找到可用服务器的错误时,检查以下四个关键步骤:1) 确保启动类有Nacos发现、Feign客户端的启用注解;2) 配置Nacos服务器地址在两端的yml文件中;3) 编写OpenFeign接口,指定服务提供者;4) 开启服务端的Endpoint以暴露健康检查。通过这些步骤,通常能排查并解决问题。
6473

被折叠的 条评论
为什么被折叠?



