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

Eureka Server无法读取Spring Cloud Config Server配置的问题排查

问题原因及解决方案

核心错误点

  1. Config Server配置冲突:同时配置了Git和Native两种配置源模式,导致Native模式未正确加载
  2. 配置文件路径/命名不匹配:Config Server无法根据Eureka Server的应用名eserver找到对应配置文件

具体修正步骤

1. 修复Config Server的配置

修改application.properties,移除Git相关配置,正确配置Native模式:

server.port=8888
spring.application.name=spring-cloud-config-server
# 指定Native模式下的配置文件根路径,替换为你的实际路径
spring.cloud.config.server.native.search-locations=file:///D:/<path-to-folder>/config-repo
spring.profiles.active=native

2. 调整配置文件结构(二选一)

方式一:按应用名命名配置文件

在config-repo根目录下创建eserver.properties,将原server/application.properties中的内容复制进去:

server.port=8761
spring.application.name=eserver
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

方式二:保留子文件夹结构(需修改搜索路径)

如果要保留server子文件夹,需修改Config Server的search-locations指向该子目录:

spring.cloud.config.server.native.search-locations=file:///D:/<path-to-folder>/config-repo/server

同时确保该文件夹下的配置文件名为eserver.properties(优先匹配)或application.properties

原理说明

  • Spring Cloud Config的Native模式下,会优先根据客户端的spring.application.name查找对应名称的配置文件(如{application}.properties),找不到才会使用通用的application.properties
  • 同时配置Git和Native模式会导致配置源冲突,Native模式下应使用spring.cloud.config.server.native.search-locations指定本地配置路径,而非Git相关配置项
  • Eureka Server启动时未获取到远程配置,因此使用默认的8080端口,此时尝试连接8761端口的Eureka服务自然会出现连接拒绝错误

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 14:47:19