首页 > 基础资料 博客日记
Nacos Ignore the empty nacos configuration and get it based on dataId
2023-07-24 16:11:21基础资料围观988次
这篇文章介绍了Nacos Ignore the empty nacos configuration and get it based on dataId,分享给大家做个参考,收藏Java资料网收获更多编程知识
1.配置错误 dataId问题
启动日志:
使用properties格式的文件:
Ignore the empty nacos configuration and get it based on dataId[xxx-server] & group[DEFAULT_GROUP]
Ignore the empty nacos configuration and get it based on dataId[xxx-server.properties] & group[DEFAULT_GROUP]
Ignore the empty nacos configuration and get it based on dataId[xxx-server-dev.properties] & group[DEFAULT_GROUP]
使用yaml文件格式:
Ignore the empty nacos configuration and get it based on dataId[xxx-server] & group[DEFAULT_GROUP]
Ignore the empty nacos configuration and get it based on dataId[xxx-server.yaml] & group[DEFAULT_GROUP]
Ignore the empty nacos configuration and get it based on dataId[xxx-server-dev.yaml] & group[DEFAULT_GROUP]
官方介绍:
在 Nacos Spring Cloud 中,dataId
的完整格式如下:
${prefix}-${spring.profiles.active}.${file-extension}
prefix
默认为spring.application.name
的值,也可以通过配置项spring.cloud.nacos.config.prefix
来配置。spring.profiles.active
即为当前环境对应的 profile,详情可以参考 Spring Boot文档。 注意:当spring.profiles.active
为空时,对应的连接符-
也将不存在,dataId 的拼接格式变成${prefix}.${file-extension}
file-exetension
为配置内容的数据格式,可以通过配置项spring.cloud.nacos.config.file-extension
来配置。目前只支持properties
和yaml
类型。
踩坑:之前习惯yaml配置文件使用yml后缀,因此在nacos服务器配置时,仍然使用yml。这个错误的!!!
第二种问题:
配置了namespace和group。 如果配置了namespace,需要在配置文件中指定具体的namespace,例如:
上面新增了namespace和group后,发现找不到配置文件。
我们需要钱nacos服务器上进行相关的配置。
我这里未指定命名空间ID.(其实项目中配置文件,namespace的值是空间ID,不是空间名称)
自动生成:
文件配置:
继续启动服务,发现仍然报错。
原因是namespce未使用命名空间ID,修改后,再启动:
因为是轮询,匹配到第三个,项目启动成功!!
文章来源:https://blog.csdn.net/qq_33642970/article/details/129195621
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签:
相关文章
最新发布
- springboot~3.x项目中使用集成测试
- Java测试类、工具类与JavaBean对比解析
- SpringBoot-日志
- springboot~http2的支持
- 解疑释惑 - 日志体系之 slf4j + logback 组合(一)
- Web server failed to start. Port 8080 was already in use. 端口被占用
- Springboot 项目配置多数据源
- 伙伴匹配系统(移动端 H5 网站(APP 风格)基于Spring Boot 后端 + Vue3 - 05
- 剑指offer-23、搜索⼆叉树的后序遍历序列
- 一个表示金额的数字是 100000000L,这是多少米?