【问题标题】:How do I use access.properties variables in an Azure Spring Boot deployed app?如何在 Azure Spring Boot 部署的应用程序中使用 access.properties 变量?
【发布时间】:2021-09-11 01:03:17
【问题描述】:

我有一个 Azure 应用服务,它正在运行我的 Spring Boot 应用,但在某些类中,我使用 @Value("${}") 注释,从 access.properties 文件中访问变量。但它似乎不适用于已部署的应用程序(生产)。

【问题讨论】:

  • 如何在生产中部署?它是 JAR 还是 WAR,它是否在 Docker 容器中运行?当你说 access.properties 时,我怀疑 Spring-Boot 正在查看默认的 application.properties 文件。
  • 这是一个 .jar,我没有运行容器

标签: spring-boot azure production-environment


【解决方案1】:

[回答我的问题]

看起来,我可以简单地将 application.properties 变量放在 Setting > Configuration > Application Settings 选项卡中,添加为 name:value

那么 Spring 已经找到了带有 @Value("${name}") 注释的值

BONUS:application.properties 文件应该是这样的,如果你使用的是 Git CI/CD

【讨论】:

    猜你喜欢
    • 2020-04-13
    • 2017-12-21
    • 1970-01-01
    • 2017-09-30
    • 2021-09-27
    • 2016-06-13
    • 2015-04-14
    • 2014-09-10
    • 1970-01-01
    相关资源
    最近更新 更多