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. winfrom中pictureBox控件的部分使用方法

    一.后台属性 1.pictureBox1.Image显示图片 2.pictureBox1.ImageLocation存储和提取图片路径 二.面板属性 1.Picturebox控件SizeMode属性 ...

  2. @Transactional 事务说明

    这里面有几点需要大家留意:A. 一个功能是否要事务,必须纳入设计.编码考虑.不能仅仅完成了基本功能就ok.B. 如果加了事务,必须做好开发环境测试(测试环境也尽量触发异常.测试回滚),确保事务生效.C ...

  3. LinkedList使用方法

    特有功能 void addFirst(E e);//在索引为0的位置添加指定元素 void addLast(E e);//在索引为size()-1的位置添加指定元素 E getFirst() 获取索引 ...

  4. React Native的学习资源网址

    react官方文档(英文): https://facebook.github.io/react/docs/getting-started.html   react中文社区(内部有视频教程等): htt ...

  5. 写一个小CTF平台

    0x00.前言 协会要举办信息安全大赛了,初赛的web+crypto+misc主要由我来出题,注册.比赛的平台也都要由我来写    上周日完成了注册页面的后端(前端由另一个女生写的),前天下午大概完成 ...

  6. C#少量数据分页方法

    string sql = @"select [Name],[Value],[TypeCode] from [dbo].[SYS_Parameter] WHERE TypeCode = 'Us ...

  7. VXLAN实验

    拓扑图: SPINE配置: hostname SPINE-1vdc SPINE-1 id 1 limit-resource vlan minimum 16 maximum 4094 limit-res ...

  8. 【c # 数据库】存储过程

    可理解存储过程是方法,快速调用,方便使用. 数据库建立新的存储过程: CREATE PROCEDURE myProc -- Add the parameters for the stored proc ...

  9. JS 中常见数组API使用方法(join、concat、slice、splice、reverce)

    刚接触前端不久,个人觉得学习程序还是需要经常总结的.下面是我的一些知识的归纳总结,如果哪里说得不对的还请各位大神指点! 1.to str (1)String(arr)将数组中的每个元素转为字符串并用逗 ...

  10. python psycopg2 连接pg 建立连接池

    # -*- coding: utf-8 -*-from psycopg2.pool import ThreadedConnectionPool,SimpleConnectionPool,Persist ...