【问题标题】:Profiles not working in spring boot jar配置文件在 Spring Boot jar 中不起作用
【发布时间】:2016-03-01 18:17:15
【问题描述】:

我有一个自定义的 spring boot jar,它依赖于文件“application.properties”和环境特定的变体,例如:

application-dev.properties
application-qa.properties
application-uat.properties

我在另一个 Spring Boot 项目中使用这个 jar,活动配置文件为“dev”。

目前我无法选择特定于 env 的属性。如何做到这一点?

一个示例错误是:

Could not resolve placeholder 'custom.url' in string value "${custom.url}"

但如果我特别使用 @PropertySource 指定文件,这将有效。

【问题讨论】:

  • 恐怕我不明白你的设置。你有没有偶然在另一个肥罐里加了一个肥罐?你说的spring boot jar,是指spring boot app吗?
  • 不只是一个罐子。不是胖子

标签: spring spring-boot


【解决方案1】:

mvn spring-boot:run -Drun.arguments="--spring.profiles.active=local"

如果你使用上面的命令,那么它可以选择application-local.properties

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 2017-09-07
    • 2021-08-30
    • 2017-10-08
    • 1970-01-01
    • 2019-02-04
    • 2019-08-25
    相关资源
    最近更新 更多