【发布时间】:2025-12-23 03:50:11
【问题描述】:
我的项目(微服务)正在使用 Spring Boot 2.1.x 和 Spring Cloud Greenwich.SR5。我想升级到 Spring Boot 2.3.x (2.3.3 RELEASE) 和 Spring Cloud (Hoxton.SR8) 但我面临服务无法从云配置服务器 (-Dspring.cloud.config.uri=http://config.abc) 获取信息的问题。
我发现https://github.com/spring-cloud/spring-cloud-config/blob/2.2.x/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java#L261 发送的是V2_JSON 而不是application/json。
谁能给我一些解决方案或解决方法?
【问题讨论】:
-
“无法获取”是什么意思?有没有错误?配置服务器也升级了吗?
-
表示我的服务无法从配置服务器获取。确定中心化服务器仍然使用 2.1.x,这就是为什么它是 application/json,而不是 V2_JSON。我正在尝试寻找某种方式来发送 application/json 而不是 V2_JSON 然后我认为我的服务可以获取云配置
-
"有什么错误吗?"还是日志中的任何内容?
-
是的,它有例外,但只是休息模板例外表示不支持媒体类型。因为我的云集中配置仍在使用 spring-boot 2.1.x(我无法触摸它)。它接受 application/json 但从 spring boot 2.2.x 它发送 V2_JSON 说明为什么我面临问题媒体类型不受支持。我正在尝试覆盖 ConfigServicePropertySourceLocator 以发送 application/json 而不是 V2_JSON。如果可能的话,我认为它应该可以工作
标签: java spring-boot microservices spring-cloud spring-cloud-config