0%

springboot-4-外部配置优先级

外部配置优先级

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

  1. 当启用devtools时,当前用户目录下的~/.spring-boot-devtools.properties 配置。Devtools global settings properties
  2. 测试时的 @TestPropertySource 注解
  3. properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
  4. 命令行参数
  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.getProperties()
  10. 操作系统环境变量
  11. A RandomValuePropertySource that has properties only in random.*.
  12. jar包外的 application-{profile}.properties and application-{profile}.ymlProfile-specific application properties
  13. jar包内的 application-{profile}.properties and application-{profile}.ymlProfile-specific application properties
  14. jar包外的 application.properties and application.yml
  15. jar包内的 application.properties and application.yml
  16. @Configuration类上的@PropertySource 注解
  17. 默认属性(specified by setting SpringApplication.setDefaultProperties)

若有 spring cloud config,默认情况 以 远端配置为准。