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

JDK11升17、SpringBoot升3.x后Spring Cloud Config服务异常

问题:Spring Cloud Config服务升级后GET请求返回405错误

服务配置信息

server:
  port: 8070

management:
  endpoints:
    web:
      exposure:
        include: info,health,monitoring,refresh,env,mappings
  security:
    enabled: "false"
  server:
    port: 18070

spring:
  cloud:
    config:
      server:
        jdbc:
          sql: SELECT key,value FROM config.properties WHERE application=? AND profile=? AND label=?
          order: 0
  datasource:
    url: jdbc:postgresql://@db.host@:5432/config_db
    username: name
    password: @db.name.pwd@
    hikari:
      connection-timeout: 5000
      maximum-pool-size: 10
      minimum-idle: 1
      idle-timeout: 10000
      data-source-properties: ApplicationName=config-server
  profiles:
    active: jdbc

问题现象

发送GET /{application}/{profile}/{label}请求获取配置属性时,收到405 HTTP响应,无法得到预期的200响应及目标属性值。

本次升级变更

Dockerfile变更

build_artifacts:
  extends: .gradle.build
  -image: ${NEXUS_DEV_REGISTRY}/docker-remote/gradle:6.9.4-jdk11-focal
  +image: ${NEXUS_DEV_REGISTRY}/docker-remote/gradle:7.5.0-jdk17-jammy

build.gradle变更

buildscript {
    ext {
        -springBootVersion = '2.1.8.RELEASE'
        +springBootVersion = '3.1.0'
    }

当前依赖版本

implementation 'org.springframework.cloud:spring-cloud-starter-config:4.0.2'
implementation "org.springframework.cloud:spring-cloud-config-server:${springBootVersion}"

原因分析

核心问题:Spring Boot与Spring Cloud版本不兼容

  • Spring Boot 3.1.0属于3.x系列,对应的Spring Cloud版本应为2022.0.x(Kilburn),而spring-cloud-starter-config:4.0.2属于2021.0.x(Jubilee)系列,该系列仅支持Spring Boot 2.6.x~2.7.x,版本不匹配导致服务内部路由映射逻辑失效,无法正确处理GET请求。
  • 错误地将Spring Boot版本号直接套用给spring-cloud-config-server:Spring Cloud组件的版本遵循独立的发布列车规则,并非与Spring Boot版本号一致,spring-cloud-config-server:3.1.0不存在,依赖解析异常进一步破坏了服务的路由配置,最终引发405错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 20:25:23