无法从“可选:configserver:http://localhost:8090 - SpringBoot 2.4.0 Illford 2020.0.0-M3”加载配置数据

问题描述 投票:0回答:2

请询问有关新 SpringBoot 2.4.0 的问题。

首先,我们将配置服务器和配置客户端升级到 SpringBoot 2.4.0 + Illford 2020.0.0-M3

然后,我们遵循设置属性的“新方式”https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4并且想要坚持这种新方式。

因此,我在 application.properties 中配置了这个(请参阅spring.config.import

server.port=8010
spring.application.name=mycoolservice
spring.config.import=optional:configserver:${SPRING_CLOUD_CONFIG_URI:https://localhost:8090}/config

然后,我们删除了旧的但有效的 bootstrap.properties

server.port=8010
spring.application.name=mycoolservice
spring.cloud.config.uri=${SPRING_CLOUD_CONFIG_URI:https://localhost:8090}/config
spring.profiles.active=${SPRING_PROFILE_ACTIVE:local}

最后,我们启动应用程序并观察到:

 ERROR [,,] 31987 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:https://localhost:8090/config'
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:124) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:111) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:114) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:125) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:114) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:106) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93) ~[spring-boot-2.4.0.jar:2.4.0]


Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:199) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:121) ~[spring-boot-2.4.0.jar:2.4.0]
    ... 30 common frames omitted

请问是什么问题?

谢谢你

java spring-boot spring-cloud-config
2个回答
3
投票

这实际上是 SpringBoot 2.4.0 + Ilford 2020.0.0-M3 组合的已知错误。

为了解决这个特定问题,SpringBoot 2.4.0需要Ilford 2020.0.0-M5。

从 M3 升级到 M5 将解决该问题。

谢谢你


0
投票

我在 application.yaml 属性中配置了它 这是我的配置服务 春天: 简介: 活跃:本机,开发IDE

应用: 名称:iap-app-service

云: 配置: 服务器: 本国的: 搜索位置:类路径:/config

© www.soinside.com 2019 - 2024. All rights reserved.