在排查一个项目问题时, 想查看下nacos服务是否正常
根据官方文档
获取配置
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"
ok官方例子没问题
由于项目里使用了 自定义的 命名空间 namespace
使用curl打开 127.0.0.1:8848/nacos/v1/cs/configs?dataId=my-order&group=DEFAULT_GROUP&namespace=xxx-xxx-xxx-xxx-xxx
页面提示 config data not exist
难道说不用加? 发现删掉namespace 也一样
翻了下github上的源码
nacos/ConfigController.java at 1.0.0-RC3 · alibaba/nacos · GitHub
public void getConfig(HttpServletRequest request, HttpServletResponse response,
@RequestParam("dataId") String dataId, @RequestParam("group") String group,
@RequestParam(value = "tenant", required = false, defaultValue = StringUtils.EMPTY)
String tenant,
@RequestParam(value = "tag", required = false) String tag)
throws IOException, ServletException, NacosException {
原来是使用了 tenant 租户这个单词来 代替yml配置中常见的 namespace
使用curl打开 修改后的 127.0.0.1:8848/nacos/v1/cs/configs?dataId=my-order&group=DEFAULT_GROUP&tenant=xxx-xxx-xxx-xxx-xxx
ok, 正常访问了