如何在groovy中获得变量的值

发布于 2025-01-22 09:13:47 字数 438 浏览 3 评论 0原文

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

我需要使用elkendpoint的值在代码中的某个地方如下:

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

我尝试使用以下,但它不起作用:

  1. 'ElasticendPoint':elkendpoint, 2“弹性点”:$ {elkendpoint}, 3“弹性点”:$ elkendpoint,

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

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

I need to use value of elkEndpoint somewhere in code like below:

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

I tried using below, but its not working:

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

What is way to use value of a variable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2025-01-29 09:13:47

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

您可以做到这一点:

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

println metrics

这将输出以下内容:

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

What is way to use value of a variable?

You can do this:

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

println metrics

That will output the following:

[elasticEndpoint:https://elastic.beta.tower.am.health.ge.com/, esConnection:]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文