spring-boot - 在Spring Cloud Config中,curl客户端如何工作?

标签 spring-boot spring-cloud spring-cloud-config

在我的存储库中,有三个文件: config-client-dev.propertiesconfig-client-prod.propertiesconfig-client.properties .

我使用curl,例如:

curl http://localhost:8888/config-client/dev/master
curl http://localhost:8888/config-client/prod/master
curl http://localhost:8888/config-client/default/master

我得到的结果是这样的:

{"name":"config-client","profiles":["prod"],"label":"master","version":null,"state":null,"propertySources":[]}

有什么方法可以获取属性文件中的值吗?

最佳答案

你的结果

{
   "name":"config-client",
   "profiles":[
      "prod"
   ],
   "label":"master",
   "version":null,
   "state":null,
   "propertySources":[
      
   ]
}

这是错误的。您必须调用

curl http://localhost:8888/config-client/dev
curl http://localhost:8888/config-client/prod
curl http://localhost:8888/config-client/default

(删除分支名称master)

让我们看一下引用文档中的示例:https://docs.spring.io/spring-cloud-config/docs/2.2.5.RELEASE/reference/html/#_quick_start

enter image description here

关于spring-boot - 在Spring Cloud Config中,curl客户端如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64085686/

相关文章:

spring-boot - 错误 : Field job in required a bean of type 'org.springframework.batch.core.Job' that could not be found

java - 有没有办法在 Spring Boot 应用程序中获取加载的属性文件列表?

rest - 边缘服务发现

java - 带有配置服务器的 Spring Cloud Eureka

java - Spring Boot GraphQL 无法加载架构

java - 使用 org.springframework.oxm jaxb2marshaller 追加 CDATA

spring-cloud - ConfigServerHealthIndicator 未检查正确的配置文件

java - Spring Cloud Gateway 还是 Zuul2,哪个是 Zuul1 的正确替代品?

spring-boot - 如何在 WebMvcTest 中禁用 Eureka 和 Spring Cloud Config?

java - 如果配置包含加密条目,嵌入式自配置 Spring-Cloud-Config 服务器启动失败