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

    配置文件覆盖顺序:(加载顺序从1->9,但在之前会确定用哪个activeProfiles,覆盖顺序1-9)
    (1)默认配置:defaultProfiles(默认配置,springboot源代码提供的)
    (2)属性配置:propertySources(写在代码中注解上的)
    (3)Servlet初始化参数配置:servletConfigInitParams(配置给servlet全局的)
    (4)Servlet全局上下文配置:servletContextInitParams(配置给servlet上下文的)
    (5)系统配置配置:systemProperties(system.setProperty()方法配置的)
    (6)系统环境配置:systemEnvironment(例如:classpath,path这种系统级别的)
    (7)随机值配置:random(springboot随机值生成器,配置文件中${random.xxx}配置)
    (8)系统环境配置(内):applicationConfig(内,覆盖顺序为:java -jar -Dspring.config.location=指定文件、./config/目录下、./目录下、classpath下)
    (9)系统环境配置(外):applicationConfig(外,覆盖顺序同上)

    备注:若要在jar包外使用application.yml或application.properties的配置,activeProfiles值一定要在外配置,且不能是空字符串,即如下图,否则该值会用jar包内的值

    例如:输出org.springframework.core.env.Environment对象可知
    StandardServletEnvironment {
      activeProfiles=[nanning],
      defaultProfiles=[default],
      propertySources=[
        StubPropertySource {name='servletConfigInitParams'},
        StubPropertySource {name='servletContextInitParams'},
        MapPropertySource {name='systemProperties'},
        SystemEnvironmentPropertySource {name='systemEnvironment'},
        RandomValuePropertySource {name='random'},
        MapPropertySource {name='applicationConfig: [classpath:/application-nanning.yml]'},
        MapPropertySource {name='applicationConfig: [file:config/application.yml]'},
        MapPropertySource {name='applicationConfig: [file:./config/application.yml]'},
        MapPropertySource {name='applicationConfig: [classpath:/application.yml]'}
      ]
    }

    更详细参见

      https://www.cnblogs.com/softidea/p/5759180.html

  • 相关阅读:
    unity与android交互总结
    Unity3d 下websocket的使用
    Unity的Shader如何控制投影颜色
    _LightColor0将会是主要的directional light的颜色。
    Unity shader saturate
    今天写shader流光效果,shader代码少了个括号,unity shader compiler卡死且不提示原因
    欧几里得空间
    Unity ios、android、pc一键打包(一)
    [AR]高通Vuforia Getting Started
    unity3d 为什么要烘焙?烘焙作用是为了什么?
  • 原文地址:https://www.cnblogs.com/chendeming/p/8334099.html
Copyright © 2011-2022 走看看