在我的存储库中,有三个文件: config-client-dev.properties
、 config-client-prod.properties
和 config-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
关于spring-boot - 在Spring Cloud Config中,curl客户端如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64085686/