zoukankan      html  css  js  c++  java
  • spring boot 配置文件加载顺序

    Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. You can use a variety of external configuration sources, include Java properties files, YAML files, environment variables, and command-line arguments.

    Property values can be injected directly into your beans by using the @Value annotation, accessed through Spring’s Environment abstraction, or be bound to structured objects through @ConfigurationProperties.

    Spring Boot uses a very particular PropertySource order that is designed to allow sensible overriding of values. Properties are considered in the following order (with values from lower items overriding earlier ones):

    Default properties (specified by setting SpringApplication.setDefaultProperties).
    
    @PropertySource annotations on your @Configuration classes. Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
    
    Config data (such as application.properties files)
    
    A RandomValuePropertySource that has properties only in random.*.
    
    OS environment variables.
    
    Java System properties (System.getProperties()).
    
    JNDI attributes from java:comp/env.
    
    ServletContext init parameters.
    
    ServletConfig init parameters.
    
    Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property).
    
    Command line arguments.
    
    properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
    
    @TestPropertySource annotations on your tests.
    
    Devtools global settings properties in the $HOME/.config/spring-boot directory when devtools is active.
    

    Config data files are considered in the following order:

    Application properties packaged inside your jar (application.properties and YAML variants).
    
    Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
    
    Application properties outside of your packaged jar (application.properties and YAML variants).
    
    Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
    
    喜欢关注一下,不喜欢点评一下
  • 相关阅读:
    XPath使用示例
    CSS3中的弹性布局——"em"的用法
    Sublime Text3快捷键实用总结
    学习笔记——关于HTML(含HTML5)的块级元素和行级(内联)元素总结
    JavaScript中的伪数组理解
    深入理解浏览器兼容性模式
    javascript 中使用instanceof需要注意的一点
    用人工智能学习,凡亿推出PCB问题解答智能搜索机器人:pcb助手
    Altium中坐标的导出及利用坐标快速布局
    Altium中Logo的导入方法及大小调整
  • 原文地址:https://www.cnblogs.com/chengmuyu/p/15269894.html
Copyright © 2011-2022 走看看