【问题标题】:Spring Boot external configuration without ignoring the packaged configurationSpring Boot 外部配置不忽略打包配置
【发布时间】:2017-11-29 08:16:07
【问题描述】:

我正在开发一个 Spring Boot JAR 应用程序,我想要在外部路径中找到一些配置属性。我想要这样的东西:

位于/home/myapps/my-spring-boot-app.jar的jar

配置位于/apps/configuration/app/config.properties

我已经使用 layout:ZIP 设置了 spring-boot-maven-plugin 并且我尝试了不同的配置,例如 spring.config.location="/apps/configuration/app/"loader.path="/apps/configuration/app/",但它没有工作。

在某些情况下,它忽略了我的外部配置,在某些情况下,它忽略了我的打包配置。我不想使用 Spring Boot 定义的层次结构,在 ./config/ 中进行配置

感谢您的帮助

【问题讨论】:

    标签: spring-boot


    【解决方案1】:

    根据文档:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.htmlspring.config.location 可以接受多个文件,因此您可以尝试以下操作:

    spring.config.location=classpath:/application.properties,/apps/configuration/app/config.properties 或只是目录: spring.config.location=classpath:/,/apps/configuration/app/

    【讨论】:

    • 我昨天已经列出了数百个类似的帖子,但没有一个人有这个建议。我的朋友,你是救生员!
    • 谢谢,很高兴能帮上忙 :)
    猜你喜欢
    • 2018-06-21
    • 2017-11-26
    • 1970-01-01
    • 2019-08-17
    • 2014-10-10
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-01-05
    相关资源
    最近更新 更多