【问题标题】:Fetch application properties from an embedded jar - Spring Boot从嵌入式 jar 中获取应用程序属性 - Spring Boot
【发布时间】:2017-01-19 16:15:38
【问题描述】:

我有一个依赖 jar 文件,我已将其添加为依赖项。有没有办法使用依赖 jar 中存在的 application.properties 文件来获取?

【问题讨论】:

    标签: java spring spring-boot properties


    【解决方案1】:

    让属性 spring.config.location 指向那个 application.properties 喜欢

    spring.config.location=classpath:com/company/whatever/application.properties
    

    启动应用时可以在命令行设置spring.config.location

    $ java -jar myproject.jar --spring.config.location=classpath:com/company/whatever/application.properties
    

    spring boot docs 对此进行了解释

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      • 2017-06-17
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 2014-01-07
      • 2022-10-14
      相关资源
      最近更新 更多