https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

Externalized Configuration

Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration. 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:

  1. Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active).
  2. @TestPropertySource annotations on your tests.
  3. properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
  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. RandomValuePropertySource that has properties only 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 by setting SpringApplication.setDefaultProperties).

Spring Boot Externalized Configuration的更多相关文章

  1. Spring boot的@Configuration

    就在我惊艳于spring 4的AbstractAnnotationConfigDispatcherServletInitializer小巧简洁(如下)的时候却发现spring boot下面竟然无效. ...

  2. Spring Boot通过Configuration配置多数据源

    本文结合SpringBoot + MyBatis + MySql进行多数据源配置,DataSource信息采用自定义dataSource.properties进行配置. 1.文件结构如下: 2.1 p ...

  3. Spring boot 使用 configuration 获取的属性为 null

    1. 未设置 getter(),setter()方法,导致属性值注入失败: 2. spring 未扫描到该组件,在其他类中注入该对象失败,可在配置类添加 @configuration 或者 @comp ...

  4. spring boot -Properties & configuration

    72. Properties & configuration72.1 Automatically expand properties at build timeRather than hard ...

  5. idea 启动项目提示 Command line is too long. Shorten command line for Application or also for Spring Boot default configuration.

    在.idea 文件夹中打开workspace.xml文件找到<component name="PropertiesComponent">,在标签里加一行  <pr ...

  6. 【springcloud】【idea】启动服务报错Command line is too long. Shorten command line for XXXApplication or also for Spring Boot default configuration.

    在workspace.xml 在标签<component name="PropertiesComponent">里 添加<property name=" ...

  7. Error running 'App': Command line is too long. Shorten command line for App or also for Spring Boot default configuration.

    找到标签 <component name="PropertiesComponent">.在标签里加一行  : <property name="dynam ...

  8. Spring Boot 所有相关的配置信息

    加载顺序 如上图所示,图片是从官网上截取的,这些配置信息都会加载,只不过顺序在前的会覆盖掉后面的 上图的所有配置信息都会以(key,value)的形式加载到Spring中的Environment中,也 ...

  9. Spring Boot 探索系列 - 自动化配置篇

    26. Logging Prev  Part IV. Spring Boot features  Next 26. Logging Spring Boot uses Commons Logging f ...

随机推荐

  1. django项目 报错:ImportError: cannot import name choice

    今天项目开发中遇到一个错误,排查了很久才发现原因,现在分享出来,希望对大家有所帮助. 错误描述:在项目中添加了一个random.py的类,导入random中的choice,并在randstr方法中使用 ...

  2. Game Engine Architecture 6

    [Game Engine Architecture 6] 1.Data-Parallel Computations A GPU is a specialized coprocessor designe ...

  3. android sdk更新后出现please update ADT to the latest version的解决方法

    参考:https://www.cnblogs.com/wicub/p/3613353.html 把 1.修改android-sdk-windows/tools/lib下的plugin.pro文件,用记 ...

  4. flask中缓存cache导入时引发的错误

    安装 pip install flask-cache 初始化 from flask_cache import Cache cache = Cache(config={ 'CACHE_TYPE': 's ...

  5. Python数据结构与算法相关问题与解决技巧

      1.如何在列表, 字典, 集合中根据条件筛选数据¶ In [1]: from random import randint In [2]: data = [randint(-10,10) for _ ...

  6. c# webBrowser 转图片

    class NativeMethods { [ComImport] [Guid("0000010D-0000-0000-C000-000000000046")] [Interfac ...

  7. Python设计模式 - UML - 时序图(Sequence Diagram)

    简介 时序图表示参与者与对象之间.对象与对象之间的动态交互过程及时序关系. 时序图详细而直观地展示了对象随时间变化的状态.调用关系和消息时序,时序图中的主要元素有:参与者(Actor), 对象(Obj ...

  8. jq动画设置图片抽奖

    (因为自己是前端刚入门的小白所以中间出现很多问题,不过这对于我来说就是一次经验的积累) 预想效果:点击"开始",图片循环旋转,不是同时的效果,而是有一定的时间差.点击"开 ...

  9. 20175126《Java程序设计》第七周学习总结

    # 20175126 2016-2017-2 <Java程序设计>第七周学习总结 ## 教材学习内容总结 - 本周学习方式主要为手动敲代码并理解内容学习. - 学习内容为教材第八章,本章主 ...

  10. 通信导论-IP数据网络基础(4)

    IP地址的编址方法--IP地址+掩码地址=网络地址 分类的IP地址 每一类地址都由两个固定长度的字段组成,其中一个字段是网络号 net-id,标志主机或路由器所连接到的网络,另一个字段则是主机号 ho ...