sofastack / sofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.
https://www.sofastack.tech/sofa-boot/docs/Home
Apache License 2.0
4.92k stars 1.26k forks source link

SofaBoot:4.2.0 服务不能正常注册到 Nacos 中 #1283

Closed zqiheng closed 5 months ago

zqiheng commented 5 months ago

本地测试项目可以正常启动,日志显示 Service 已经注册完成。 image

但是在 Nacos 页面上不能看见注册的 Service。

image

然后使用 Consumer 调用服务也的确报错。 image

不知道是我的配置问题还是环境或者版本问题,麻烦帮我看一下,谢谢!示例代码

使用的组件版本:

HzjNeverStop commented 5 months ago

@zqiheng 在 SOFABoot 应用中,RPC 服务的注册通常是在应用的健康检查阶段完成后才执行的,从你的 demo 里看到你并未引入健康检查相关功能,因此 RPC 服务没有自动发布。

你有两个解决方案:

  1. 引入 SOFABoot 的健康检查依赖,这样你的 RPC 服务会在健康检查通过后自动发布

        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>actuator-sofa-boot-starter</artifactId>
        </dependency>
  2. 不引入 SOFABoot 的健康检查依赖,通过配置开启 RPC 服务的自动发布:

    
    sofa.boot.rpc.enableAutoPublish=true
zqiheng commented 5 months ago

非常感谢,按照上述两种方案分别测试后,都可以注册成功!