You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Cloud Config Server远程Git仓库propertySources为空问题排查

问题分析与解决方案

你遇到的propertySources为空数组的问题,主要是两个关键错误导致的,咱们逐个排查:

1. Git认证配置的语法错误

看你application.properties里的这行配置:

spring.cloud.config.server.git.username==user_name

这里多写了一个等号!正确的配置应该是单个等号:

spring.cloud.config.server.git.username=user_name

这个语法错误会导致Config Server无法正确完成远程Git仓库的身份验证,进而无法拉取到仓库里的配置文件,最终返回空的propertySources。

2. 配置文件名与请求服务名不匹配

你远程Git仓库里的配置文件是limit-service.properties(前缀是limit-service,没有末尾的s),但你发起的请求路径是http://localhost:8888/limits-service/default(请求的服务名是limits-service,带s)。

Spring Cloud Config的匹配规则是:请求的服务名称必须和配置文件的前缀完全一致,这里名称差了一个s,导致Config Server找不到对应的配置文件,所以返回的propertySources是空的。

修复步骤

  1. 修正application.properties里的Git用户名配置,去掉多余的等号
  2. 保持服务名与配置文件名一致:
    • 要么把远程仓库里的配置文件重命名为limits-service.properties
    • 要么将请求路径改为http://localhost:8888/limit-service/default
  3. 重启Spring Cloud Config Server,再发起请求验证

修正后,你应该能在返回结果的propertySources里看到limits-service.minimum和limits-service.maximum的配置了。


内容的提问来源于stack exchange,提问作者Pri_stack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 20:12:50