Spring-Cloud爬坑集锦00001

    技术2022-07-13  78

    关于Spring-spring-boot-starter-actuator

    项目背景错误发生之前提错误之提示:解决之办法:处理之结果 梳理在服务提供者和服务消费者都没有引入 spring-boot-starter-actuator 依赖时关于 spring-boot-starter-actuator 依赖的引入 最后

    项目背景

    Spring-boot版本:2.3.1Spring-cloud版本:Hoxton.SR6服务提供者:kucun-provider:10003服务消费者:kucun-consumer:10004案发时间:kucun-consumer 整合 openfeign 中…

    错误

    发生之前提

    localhost:10003/xxx 没有问题,localhost:10004/xxx 出现错误此时 consul 中两个节点的 node checks 均为 ❌

    错误之提示:

    运行localhost:10004/xxx时错误提示: com.netflix.client.ClientException: Load balancer does not have available server for client: kucun-provider

    解决之办法:

    在两个项目中的添加依赖: spring-boot-starter-actuator

    处理之结果

    localhost:10003/xxx 没有问题,localhost:10004/xxx 没有问题此时 consul 中两个节点的 node checks 均为 ✅

    梳理

    在服务提供者和服务消费者都没有引入 spring-boot-starter-actuator 依赖时

    在 consul 中的 node checks 均为 ❌服务提供者可以访问自己的方法服务消费者出现了无法从 consul 中匹配到对应name的服务提供者的错误

    关于 spring-boot-starter-actuator 依赖的引入

    在只有服务消费者引入依赖时,服务消费者任然无法获取到对应 name 的服务提供者在只有服务提供者引入依赖时,服务消费者可以正常获取到对应 name 的服务提供者

    最后

    写这篇博文只是想证明我也努力过。XD

    Processed: 0.011, SQL: 9