csworkman

个人博客

配置文件优先级

2022-3-25 Mr Chang springboot

内部配置文件加载顺序:
-file:  ./config/
-file:  ./
-classpath:/config/
-classpath:

外部配置加载顺序:

(优先级从高到低:)

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指定的默认属性

发表评论: