簡體   English   中英

如何獲取groovy中變量的值

[英]How to get a value of variable in groovy

String elkEndpoint = 'https://elastic.beta.tower.am.health.ge.com/'

我需要在如下代碼中的某處使用elkEndpoint的值:

// Some code
'metrics': [
            'elasticEndpoint': elkEndpoint,
            'esConnection':    ''
        ],
// Some code

我嘗試在下面使用,但它不起作用:

  1. 'elasticEndpoint': elkEndpoint, 2 'elasticEndpoint': ${elkEndpoint}, 3 'elasticEndpoint': $elkEndpoint,

什么是使用變量值的方法?

什么是使用變量值的方法?

你可以這樣做:

String elkEndpoint = 'https://elastic.beta.tower.am.health.ge.com/'
Map metrics = [ elasticEndpoint: elkEndpoint, esConnection: '' ]

println metrics

那將 output 以下內容:

[elasticEndpoint:https://elastic.beta.tower.am.health.ge.com/, esConnection:]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM