Spring : Spring外部配置加载顺序

1.美图

在这里插入图片描述

2.概述

Spring Boot支持多种外部配置方式
这些方式优先级如下:
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-external-config

  1. 命令行参数
  2. 来来java:comp/env的JNDI属性
  3. Java系统属性( System.getProperties() )
  4. 操作系统环境变量
  5. RandomValuePropertySource配置的random. *属性值
  6. jar包外部的application-{profile}.properties或application.yml(带spring.profile)配置文件
  7. jar包内部的application-{profile}.properties或application.yml(带spring.profile)配置文件
  8. jar包外部的application.properties或application.yml(不带spring.profile)配置文件
  9. jar包内部的application.properties或application.yml(不带spring.profile)配置文件
  10. @Configuration注解类 上的@PropertySource
  11. 通过SpringApplication.setDefaultProperties指定的默认属性

猜你喜欢

转载自blog.csdn.net/qq_21383435/article/details/105019435