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

Spring Boot2.5.6下Config客户端通过spring.config.import拉取配置失败

问题排查与解决方案

1. 核心问题根因

File extension is not known to any PropertySourceLoader报错本质是Spring Cloud Config的配置导入解析器未被正确触发,Spring Boot把configserver:前缀的地址当成普通文件路径解析,找不到对应文件后缀就抛出了异常。

2. 具体修复步骤

步骤1:清理版本冲突依赖

你客户端和服务端都混用了低版本Spring Cloud组件,和你使用的Spring Boot 2.5.6、Spring Cloud 2020.0.4版本不兼容:

  • 删掉客户端和服务端pom里手动指定版本的spring-cloud-config-monitor、spring-cloud-starter-stream-rabbit依赖,统一交由Spring Cloud版本管理仲裁,不需要手动指定版本号。

手动指定的2.2.2.RELEASE属于Hoxton版本组件,和2020.0.4版本不兼容,会导致组件加载异常。

步骤2:调整客户端配置逻辑

你使用spring.config.import新方式的场景下,不需要引入spring-cloud-starter-bootstrap依赖,两种配置方式二选一即可:

方案A(推荐:使用spring.config.import新方式)

  • 删掉客户端pom里的spring-cloud-starter-bootstrap依赖
  • 确认客户端application.properties里保留如下配置:
spring.config.import=optional:configserver:http://localhost:8888

方案B(使用传统bootstrap方式)

  • 保留spring-cloud-starter-bootstrap依赖,删掉application.properties里的spring.config.import配置
  • 新建bootstrap.properties文件,添加如下配置:
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.enabled=true

步骤3:确认版本管理配置

确认父pom里已经引入了正确的Spring Cloud版本依赖管理:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2020.0.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

3. 验证方法

修复后启动客户端,无上述报错且可正常读取到jwt.key等远程配置项即为修复成功。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 06:09:00