【问题标题】:Setting env variables on openshift 4 and spring boot application在 openshift 4 和 spring boot 应用程序上设置环境变量
【发布时间】:2021-11-17 17:42:29
【问题描述】:

我正在使用需要部署到 openshift 4 的 spring boot 应用程序。我创建了一个私有映像注册表。 openshift 从这个私有存储库中提取图像。 我在spring boot应用程序的spring profile(名为openshift)中设置了env变量,如下所示:

  • 应用程序-openshift.yaml

弹簧: 数据源: url: jdbc:oracle:thin:@//${DB_URL} 用户名:${DB_USERNAME} 密码:${DB_PASSWORD}

数据源属性在 intellij idea 中设置为环境变量。 现在每当我将应用程序部署到 openshift 时。 spring 应用程序将配置文件作为默认配置并忽略此 openshift 配置文件。

谁能建议我做错了什么? oc env 命令在命令行中对我不起作用。

【问题讨论】:

    标签: spring-boot deployment environment-variables openshift


    【解决方案1】:

    我认为您应该提供您的 applicaton-openshift.yaml 的详细信息 但在 Openshift 中,您可以在“ENV”部分为您的容器设置环境变量。

    通常 Spring 合并环境变量和 java 属性,您可以使用环境变量覆盖属性值,但我不确定哪个版本的 Spring 开始这样做。

    在非常旧的版本中,您可以在 openshift deployconfig 中使用“-Dmy.property=my.valye”设置 JAVA_OPS 或 JAVA_OPS_APPEND 变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-19
      • 2016-11-15
      • 2016-04-03
      • 2012-06-08
      • 2017-11-14
      • 2021-12-23
      • 1970-01-01
      • 2020-06-09
      相关资源
      最近更新 更多