【发布时间】:2021-05-27 12:34:51
【问题描述】:
Spring 在 env-endpoint 提供有关环境的信息。我想简化输出,看起来像这样:
{
"propertySources": [
{
"name": "ports",
"properties": {
"server.port": {
"value": 9110
},
"management.port": {
"value": 9350
}
}
},
{
"name": "trees",
"properties": {
"oak": {
"value": "true"
}
}
},
{
"name": "elephants",
"properties": {}
},
...
}
我只想看到键值对作为输出,如下所示:
{
"server.port": 9110,
"management.port": 9350,
"oak": "true",
...
}
使用 JQ 我尝试了一些事情,开始于
curl https://localhost:9350/actuator/env/ -s | jq '[.propertySources[].properties[]]'
并尝试map、select 和with_entries,但我无法让它运行。
你能给我一个正确的方向吗?
【问题讨论】: