【问题标题】:How to override bootstrap.properties OR how to ignore cloud config for local environment in spring boot如何覆盖 bootstrap.properties 或如何在 spring boot 中忽略本地环境的云配置
【发布时间】:2022-12-14 04:39:29
【问题描述】:

我有一个在本地开发环境中运行的应用程序 [Spring boot app]。我在 bootstrap.properties 文件中使用了 AWS 参数存储配置,如下所示:

aws.paramstore.enabled = true
aws.paramstore.prefix = /abc
aws.paramstore.name = xyz/jkl/wer

这些是我在 pom.xml 文件中的依赖项:

    <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-starter-aws-parameter-store-config</artifactId>
        <version>2.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bootstrap</artifactId>
        <version>3.1.3</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-sts</artifactId>
        <version>1.12.263</version>
    </dependency>

该应用程序在上述配置下运行良好。然而,每次当我需要在本地运行我的应用程序时,我需要注释掉上面的依赖项,否则它会抛出错误,因为这些 jar 在类路径中并且他们抱怨找不到几个连接等。

我正在尝试找出一些无需在 pom.xml 中进行任何更改即可运行具有本地属性的应用程序的可能性。

我试图在 bootstrap 中将以下属性设置为 false 并在 application-dev.properties 文件中启用它,但是应用程序没有在 dev 中获取 bootstrap 配置。

#false in bootstrap, enabled in application-dev.properties
aws.paramstore.enabled = false

你能帮我解决这个问题吗?我不想每次在本地运行我的应用程序时都注释掉 pom 中的依赖项。我可以在这里使用什么技巧。

【问题讨论】:

    标签: java spring-boot aws-parameter-store


    【解决方案1】:

    我在 eclipse 中找到了一种方法:

    然而,主要问题仍然有效,我们如何在我们的应用程序环境中明智地覆盖引导程序属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-18
      • 2016-02-12
      • 2016-06-06
      • 2019-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-07
      相关资源
      最近更新 更多