sofaboot4.1.0集成nacos注册中心相关问题

前言

停留在jdk1.8的时间是不是有点多呢,所以脑海里总有一种这颗常青树不知道什么时候会倒的想法。不管它倒与不倒,前进就不会有错。


一、sofa是什么?

自行了解 sofa
代码地址: https://gitee.com/sofastack/sofa-boot

二、环境准备

  1. JDK17
  2. sofaboot-dependencies 4.1.0
  3. nacos2.0.3

三、开撸

1.pom配置

<parent>
     <groupId>com.alipay.sofa</groupId>
     <artifactId>sofaboot-dependencies</artifactId>
     <version>4.1.0</version>
     <relativePath/>
 </parent>

<dependencies>

     .................................

      <dependency>
           <groupId>com.alipay.sofa</groupId>
           <artifactId>rpc-sofa-boot-starter</artifactId>
       </dependency>
       <dependency>
           <groupId>com.alipay.sofa</groupId>
           <artifactId>tracer-sofa-boot-starter</artifactId>
       </dependency>
       <dependency>
           <groupId>com.alipay.sofa</groupId>
           <artifactId>runtime-sofa-boot-starter</artifactId>
       </dependency>
       <dependency>
           <groupId>com.alipay.sofa</groupId>
           <artifactId>actuator-sofa-boot-starter</artifactId>
       </dependency>
      .................................

</dependencies>

2.yml配置

com:
  alipay:
    sofa:
      rpc:
        registry:
          address: nacos://127.0.0.1:8848

3.启动类

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        StartupSpringApplication startupSpringApplication = new StartupSpringApplication(Application.class);
        startupSpringApplication.run(args);
    }
}

四、实际搭建遇到的问题

1.版本不匹配出现的问题

Client not connected,current status:STARTING
server is DOWNnow, detailed error message: Optional[The raft peer is in error: ERROR_TYPE_SNAPSHOT]
com.alipay.sofa.runtime.api.ServiceRuntimeException: RPC-010010009: 订阅元数据失败
Caused by: com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException: RPC-010060009: 订阅 provider 到 [NacosRegistry] 失败! 

注:原项目使用的nacos是1.x,升级到nacos2.0.3就可以搞定了。

2.启动成功,但是服务没有注册成功

SOFA-BOOT-01-21001: HealthIndicator[mailHealthContributor] readiness check fail; the status is: DOWN; the detail is: {"location":"smtp.163.com:465","error":"jakarta.mail.MessagingException: Got bad greeting from SMTP host: smtp.163.com, port: 465, response: [EOF]"}

注:配置出错导致的问题,修改yml文件配置,要正确呦!要不就痛快点,把这段删了就完了

spring:
  mail:
    host: smtp.163.com
    password: xxxx
    username: xxxx@163.com
    port: 465

总结

做升级工作也不太难,只要版本对应上,并注意新版本配置的变更,都没啥大问题。

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值