【问题标题】:Spring profile unable to parse correct fileSpring配置文件无法解析正确的文件
【发布时间】:2018-03-01 23:18:42
【问题描述】:

这是我用来读取 gradle 项目中的 application.properties 文件的代码。

@PropertySource("${spring.profiles.active}/application.properties")

我的文件位于resources/local/application.properties

这就是我尝试在 IntelliJ 中运行应用程序的方式

这是我最终得到的错误。

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.core.Application]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.profiles.active' in value "${spring.profiles.active}/application.properties"

谁能帮我解决这个问题并阅读正确的配置。

【问题讨论】:

    标签: spring spring-boot intellij-idea spring-profiles


    【解决方案1】:

    您正在尝试获取 spring.profiles.active 但在 Intellij 中您正在设置 spring.active.profiles

    【讨论】:

    • 我修复了它仍然无法正常工作。我收到以下错误org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.example.core.Application]; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.active.profiles' in value "${spring.active.profiles}/application.properties"
    • 我想你换了名字,试试 spring.profiles.active 了解更多信息检查this link
    • 我已经尝试了所有可能的组合。它不起作用。
    • 您是否尝试在参数或环境变量中而不是在 VMoptions 中进行设置?
    • @MelissaStewart 请看一下this post 我想它也可以帮助你
    猜你喜欢
    • 1970-01-01
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-11
    • 2017-07-19
    • 1970-01-01
    相关资源
    最近更新 更多