seata :no available service ‘null‘ found, please make sure registry config correct

2 篇文章 0 订阅
1 篇文章 0 订阅

记录一下这个有点坑的问题:
no available service ‘null’ found, please make sure registry config correct在这里插入图片描述
springboot 2.2.9
springcloud alibaba 2.2.1
seata 1.3
nacos 1.3.2

按照最新的seata文档搭建好后一直报这个错,根据网上的解决方案检查注册中心配置没问题

registry.conf

	registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"
  nacos {
    application = "server-seata"
    serverAddr = "xxx:8848"
    group = "DEFAULT_GROUP"
    namespace = "cloud-platform-dev"
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}

config {
  # file、nacos 、apollo、zk、consul、etcd3
  type = "nacos"
  nacos {
    serverAddr = "xxxx:8848"
    group = "DEFAULT_GROUP"
    namespace = "cloud-platform-dev"
    username = "nacos"
    password = "nacos"
  }
}



file.conf

store {
  ## store mode: file、db、redis
  mode = "db"
 ## database store property
  db {
    ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
    datasource = "druid"
    ## mysql/oracle/postgresql/h2/oceanbase etc.
    dbType = "mysql"
    driverClassName = "com.mysql.jdbc.Driver"
    url = "jdbc:mysql://xxx:3308/seata"
    user = "root"
    password = "xxxx"
    minConn = 5
    maxConn = 100
    globalTable = "global_table"
    branchTable = "branch_table"
    lockTable = "lock_table"
    queryLimit = 100
    maxWait = 5000
  }
}

客户端配置service-user-dev.yml:

seata:
  application-id: ${spring.application.name}
  enabled: true
  tx-service-group: ${spring.application.name}-group
  enable-auto-data-source-proxy: true
  config:
    type: nacos
    nacos:
      namespace: ${spring.cloud.nacos.config.namespace}
      serverAddr: xxxx:8848
      group: DEFAULT_GROUP
      userName: "nacos"
      password: "nacos"
  registry:
    type: nacos
    nacos:
      application: server-seata
      serverAddr: xxxx:8848
      group: DEFAULT_GROUP
      namespace: ${spring.cloud.nacos.config.namespace}
      userName: "nacos"
      password: "nacos"
      cluster: default

在这里插入图片描述
在这里插入图片描述

检查了service.vgroupMapping 没有问题,网上的解决方案基本上都试过了,问题没得到解决,于是我决定看看源码,通过源码我发现seata通过下面get请求从nacos上面获取配置:
http://127.0.0.1:8848/nacos/v1/ns/instance/list?app=service-user&healthyOnly=false&namespaceId=cloud-platform-dev&clientIP=192.168.0.106&serviceName=DEFAULT_GROUP%40%40server-seata&udpPort=62880&accessToken=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTU5OTc2MTU4NX0.PYtcLgh2C_X5J9-ZGpVZsmn1AmL4vVg8rWVR54zHtmI&encoding=UTF-8&clusters=null

大家注意到没有clusters = null,拿不到hosts,我们的明明是default,然后我手动测试
在这里插入图片描述

在这里插入图片描述
然后我手动改default试试,居然就拿到了,在这里我怀疑是我们配置的问题。

http://127.0.0.1:8848/nacos/v1/ns/instance/list?app=service-user&healthyOnly=false&namespaceId=cloud-platform-dev&clientIP=192.168.0.106&serviceName=DEFAULT_GROUP%40%40server-seata&udpPort=62880&accessToken=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTU5OTc2MTU4NX0.PYtcLgh2C_X5J9-ZGpVZsmn1AmL4vVg8rWVR54zHtmI&encoding=UTF-8&clusters=default
在这里插入图片描述

请求一下我对应的配置试试:
在这里插入图片描述
http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=service.vgroupMapping.my_test_tx_group&group=DEFAULT_GROUP&tenant=cloud-platform-dev&accessToken=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTU5OTc2MTU4Mn0.vASaGpQx0tlxSxzre6s9A15q9lAFvQH2lv4uCzdCRE4

返回的:
在这里插入图片描述
这怎么可能不存在,我又没瞎。

然后我请求我另外的配置:
在这里插入图片描述
在这里插入图片描述

能拿到配置,这里没问题,然后我恍然大悟,是不是我的nacos 没有刷新,于是我重启一下nacos,再次请求。
在这里插入图片描述
能拿到值了,然后我重新启动项目,果然就不报错了。
在这里插入图片描述
看到这里我想的是,在使用新技术的同时一定要养成自己解决问题的能力。加油,骚年们,老板叫我去加班了。

  • 10
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阳十三

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值