使用spring-cloud-config-server读取本地git仓库配置返回404问题求助
Spring Cloud Config Server本地Git配置404问题修复方案
导致http://localhost:8888/limits-service/default返回404的核心原因及修复方法如下:
- 本地Git仓库未初始化提交
Spring Cloud Config Server只会读取Git仓库中已提交的配置文件,不会读取工作区未提交的内容,这是本地配置场景下最常见的问题。
修复步骤:
进入D:\Learning\Microservices\git-localconfig-repo目录,依次执行以下命令:git init git add limits-service.properties git commit -m "首次提交配置文件" - 配置文件名称或路径错误
请检查两项内容:- 确认
git-localconfig-repo目录下直接存放limits-service.properties,没有嵌套子文件夹 - 开启Windows系统的文件后缀名显示,确认配置文件后缀为
.properties,不是被系统自动隐藏的.properties.txt
- 确认
- Git路径配置格式问题
Windows下本地Git仓库的URI推荐使用以下写法,替换config server的application.properties中对应配置即可:spring.cloud.config.server.git.uri=file:///D:/Learning/Microservices/git-localconfig-repo - 版本兼容性问题
Spring Boot 2.4.5对应适配的Spring Cloud版本为2020.0.x(代号Ilford),请检查pom.xml中Spring Cloud版本依赖配置是否匹配,避免版本不兼容导致Config Server端点不注册。
所有配置修正后重启Spring Cloud Config Server,再次访问目标地址即可正常返回配置内容。
内容的提问来源于stack exchange,提问作者Abhishek
相关产品推荐
相关产品推荐

