<tfoot id='G78uW'></tfoot>
    1. <legend id='G78uW'><style id='G78uW'><dir id='G78uW'><q id='G78uW'></q></dir></style></legend>
      1. <i id='G78uW'><tr id='G78uW'><dt id='G78uW'><q id='G78uW'><span id='G78uW'><b id='G78uW'><form id='G78uW'><ins id='G78uW'></ins><ul id='G78uW'></ul><sub id='G78uW'></sub></form><legend id='G78uW'></legend><bdo id='G78uW'><pre id='G78uW'><center id='G78uW'></center></pre></bdo></b><th id='G78uW'></th></span></q></dt></tr></i><div id='G78uW'><tfoot id='G78uW'></tfoot><dl id='G78uW'><fieldset id='G78uW'></fieldset></dl></div>
          <bdo id='G78uW'></bdo><ul id='G78uW'></ul>

      2. <small id='G78uW'></small><noframes id='G78uW'>

      3. 如何在 .yml 文件中使用属性占位符

        时间:2023-09-26

        <small id='1SQZX'></small><noframes id='1SQZX'>

          • <bdo id='1SQZX'></bdo><ul id='1SQZX'></ul>
                  <tbody id='1SQZX'></tbody>
              • <i id='1SQZX'><tr id='1SQZX'><dt id='1SQZX'><q id='1SQZX'><span id='1SQZX'><b id='1SQZX'><form id='1SQZX'><ins id='1SQZX'></ins><ul id='1SQZX'></ul><sub id='1SQZX'></sub></form><legend id='1SQZX'></legend><bdo id='1SQZX'><pre id='1SQZX'><center id='1SQZX'></center></pre></bdo></b><th id='1SQZX'></th></span></q></dt></tr></i><div id='1SQZX'><tfoot id='1SQZX'></tfoot><dl id='1SQZX'><fieldset id='1SQZX'></fieldset></dl></div>
                <tfoot id='1SQZX'></tfoot>

                  <legend id='1SQZX'><style id='1SQZX'><dir id='1SQZX'><q id='1SQZX'></q></dir></style></legend>
                  本文介绍了如何在 .yml 文件中使用属性占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Java 和 Spring Boot.我想知道如何将属性占位符添加到 .yml 文件中.我找到了一些清晰的示例,但我不确定属性占位符在哪里被实例化.是在系统环境变量、文件等中吗?

                  I am working with Java and spring boot. I was wondering how to add Property placeholders into .yml files. I've found some crisp examples but I am not sure where are the Property placeholders are being instantiated in. Is it in system env variables, a file, etc..?

                  Bootstrap.yml

                  spring:
                    cloud:
                      config:
                        username: ${my.stored.files.username}
                        password: ${my.stored.files.password}
                        label: ${spring.cloud.find.label}
                        uri: ${spring.cloud.config.uri}
                        enabled: false
                        failFast: true
                  

                  用户正在使用属性占位符,但用户在哪里声明了它们?这个 .yml 从哪里读取值?(与上述相同的问题)是否有解释连接的文件?

                  User is using Property placeholders, but where did the user declared them? Where is this .yml reading the values from? (same question as above) Is there a document that explains the connection?

                  这个 Web 应用程序将使用cf push"推送到 Cloud Foundry,它会自动选择 manifest.yml 文件进行配置.如果可能的话,一个云代工厂的例子会很棒.

                  This web application will be pushed to cloud foundry using "cf push", Which will automatically pick manifest.yml file to configure. If possible a cloud foundry example would be great.

                  了解/示例 Application.properties 文件

                  app.name=MyApp
                  app.description=${app.name} 
                  

                  用户能够使用 ${app.name} 因为它已定义.我对上面的例子感到困惑.用户如何以及在何处获得${my.stored.files.username}".这是在哪里定义的?我认为它会在 system.properties 或环境变量中.谁能确认一下?

                  User was able to use ${app.name} because it is defined. I am confused on the example above. How and where is the user getting "${my.stored.files.username}. Where is that being defined? I assumed it would be in system.properties or environment variables. Can anyone confirm?

                  推荐答案

                  经过深入研究,我发现当我在 .yml 文件中使用占位符时,它会从环境变量中读取该值.这是我一开始的理论的一部分,但没有人证实.

                  After intensive research, I was able to find that when I use placeholders in .yml files it reads that values from environment variables. Which was part of my theory in the beginning, but no one has confirmed.

                  当地环境的答案

                  spring:
                    cloud:
                      config:
                        username: ${my.stored.files.username}
                        password: ${my.stored.files.password}
                        label: ${spring.cloud.find.label}
                        uri: ${spring.cloud.config.uri}
                        enabled: false
                        failFast: true
                  

                  *在环境变量中*

                  set key as: my.stored.files.username
                  set value as: UsernameSample
                  

                  那么

                  当你运行应用程序时,yml 会这样读取.

                      config:
                        username: ${my.stored.files.username}
                                  //gets replaced with UsernameSample
                  

                  这是解决我的问题的链接链接

                  This is the link that solved my problem link

                  对于 Cloudfoundry

                  您必须创建杯子或手动将这些变量添加到服务中.

                  You would have to create cups or manually add these variables onto the service.

                  这篇关于如何在 .yml 文件中使用属性占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Spring Boot 中的多态配置属性 下一篇:JACOB 没有正确释放对象

                  相关文章

                  最新文章

                  • <bdo id='UbBxg'></bdo><ul id='UbBxg'></ul>
                  <tfoot id='UbBxg'></tfoot>

                1. <small id='UbBxg'></small><noframes id='UbBxg'>

                  <legend id='UbBxg'><style id='UbBxg'><dir id='UbBxg'><q id='UbBxg'></q></dir></style></legend>

                  <i id='UbBxg'><tr id='UbBxg'><dt id='UbBxg'><q id='UbBxg'><span id='UbBxg'><b id='UbBxg'><form id='UbBxg'><ins id='UbBxg'></ins><ul id='UbBxg'></ul><sub id='UbBxg'></sub></form><legend id='UbBxg'></legend><bdo id='UbBxg'><pre id='UbBxg'><center id='UbBxg'></center></pre></bdo></b><th id='UbBxg'></th></span></q></dt></tr></i><div id='UbBxg'><tfoot id='UbBxg'></tfoot><dl id='UbBxg'><fieldset id='UbBxg'></fieldset></dl></div>