【问题标题】:Spring Application.Properties and Application-dev.properties files parameter conflictSpring Application.Properties 和 Application-dev.properties 文件参数冲突
【发布时间】:2020-04-13 14:20:54
【问题描述】:

我的 application.properties 文件中的配置文件逻辑。我的问题是当我使用 -dev 时,它从 application-dev.properties 读取值。但是我有相同的密钥,它在我的 application-dev.properties 中不存在但存在于application.properties,spring继续从application.properties中读取值

application.properties
myfirstkey=x
mysecondkey=x

application-dev.properties
mysecondkey=dev

-Dspring.profiles.active=dev (// I pass profile value and see result by the way)

输出mysecondkey dev,没问题没问题 输出myfirstkey为x(我的期望为空),但在application-dev.properties中不存在?有没有办法阻止application.properties读取

【问题讨论】:

    标签: spring spring-boot application.properties


    【解决方案1】:

    好吧,application.properties 基本上是您的“默认”.properties,您不能只是(根据具体情况)禁用它们,因此解决方法是在您的 -dev.properties 中执行此操作。

    myfirstkey=
    

    【讨论】:

      猜你喜欢
      • 2018-11-04
      • 1970-01-01
      • 2014-11-21
      • 2016-12-04
      • 2011-11-23
      • 2016-08-08
      • 1970-01-01
      • 2012-08-27
      • 2015-02-23
      相关资源
      最近更新 更多