
nacos配置获取不到
Bug 描述
nacos配置获取不到
错误信息
▼text复制代码2025-11-04 10:41:48.159 WARN 19028 --- [ restartedMain] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[test] & group[DEFAULT_GROUP] 2025-11-04 10:41:48.162 WARN 19028 --- [ restartedMain] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[test.yaml] & group[DEFAULT_GROUP] 2025-11-04 10:41:48.164 WARN 19028 --- [ restartedMain] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[test-dev.yaml] & group[DEFAULT_GROUP] 2025-11-04 10:41:48.165 INFO 19028 --- [ restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-test-dev.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-test.yaml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-test,DEFAULT_GROUP'}] 2025-11-04 10:41:48.168 INFO 19028 --- [ restartedMain] c.v.usercenter.UserCenterApplication : The following 1 profile is active: "dev" 2025-11-04 10:41:48.184 WARN 19028 --- [ restartedMain] c.a.c.n.c.NacosConfigDataLoader : [Nacos Config] config[dataId=test, group=DEFAULT_GROUP] is empty
pom配置如下:
▼text复制代码<dependencies> <!-- Nacos 配置中心依赖 --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <!-- Spring Cloud 版本管理(关键新增) --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>2021.0.4</version> <!-- 与 Spring Boot 2.6.x 兼容的版本 --> <type>pom</type> <scope>import</scope> </dependency> <!-- Spring Cloud Alibaba 版本管理 --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2021.0.4.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
bootstrap配置如下:
▼text复制代码spring: application: name: usercenter # 服务名(对应 Nacos 配置的 Data ID 前缀) profiles: active: dev cloud: nacos: config: server-addr: 127.0.0.1:8848 # Nacos 服务器地址(多个用逗号分隔) file-extension: yaml # 配置文件格式(yaml 或 properties) # 可选配置 namespace: public # 命名空间(隔离环境,默认 public) group: DEFAULT_GROUP # 配置分组(默认 DEFAULT_GROUP) # 配置刷新策略(默认开启自动刷新) refresh-enabled: true username: nacos password: nacos config: import: - nacos:${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}?group=${spring.cloud.nacos.config.group}
自己在nacos上的public命名空间下创建了dataid为usercenter-dev.yaml的文件,配置如下
▼text复制代码spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/user_center?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai username: root password: xxxx
当前环境为java8,springboot2.7,nacos2.2.0
评论
相关内容
0个评论
全部评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
内容推荐
第1章 LearnWise AI项目介绍
5
Spring Boot 如何处理跨域请求(CORS):深度调研报告
3
【入职求助贴】萌新刚入职某大厂做后端开发,目前还在试用期。最近遇到一个棘手的问题,想向大家求助一下。入职不久,leader 给我派了一个任务。跟我说是0.5天就可以解决,我刚毕业入职,做了一个星期没有做出来。实现一个收集定时成功任务的案例。听起来好像不复杂,但我自己摸索着做了一整个星期,到现在还没达到预期效果。这一周我基本是“边学边做”的状态,遇到卡点也会每天主动找 leader 沟通进度和疑问。
2
最近在使用ChatGPT/Codex过程中发现了一个官方bug:高频日志写盘,会损坏电脑磁盘的寿命。桌面版和CLI都有这个问题,目前最新版的ChatGPT/Codex还没有彻底解决这个问题(虽然官方自称已经修复了,但实测还是有高频日志写盘问题)。建议使用下面这段提示词发给AI让它检查和修复:帮我检查 ~./codex/logs_2.sqlite 是否因 TRACE 日志持续高频写盘;如果中招,先备
2
#字节内推# 实习、校招、社招均有岗位
4
