zoukankan      html  css  js  c++  java
  • Spring Boot配置加载顺序

    如果加载的配置有重复的,它们的加载顺序是这样的,数字越小的优先级越高,即优先级高的覆盖优先级低的配置。

    1. Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active).
    2. @TestPropertySource annotations on your tests.
    3. @SpringBootTest#properties annotation attribute on your tests.
    4. Command line arguments.
    5. Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property)
    6. ServletConfig init parameters.
    7. ServletContext init parameters.
    8. JNDI attributes from java:comp/env.
    9. Java System properties (System.getProperties()).
    10. OS environment variables.
    11. A RandomValuePropertySource that only has properties in random.*.
    12. Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants)
    13. Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants)
    14. Application properties outside of your packaged jar (application.properties and YAML variants).
    15. Application properties packaged inside your jar (application.properties and YAML variants).
    16. @PropertySource annotations on your @Configuration classes.
    17. Default properties (specified using SpringApplication.setDefaultProperties).

    知道了它们的加载顺序,我们就能知道从哪一步来替换配置。

    http://www.javastack.cn/article/2017/spring-boot-config-load-order/

  • 相关阅读:
    C++标准库vector以及迭代器
    (转)单链表的逆置
    (六)通过solr7的API实现商品的列表查询
    (八)solr7实现搜索框的自动提示并统计词频
    (四)DIH导入结构化数据
    (三)Solrj4到Solrj5的升级之路
    easyui validatebox 验证类型
    一、docker临时记录
    vip视频网站爬虫
    Intellij IDEA 4种配置热部署的方法
  • 原文地址:https://www.cnblogs.com/panchanggui/p/10764471.html
Copyright © 2011-2022 走看看