yml和properties加载顺序
时间: 2023-04-12 15:02:33 浏览: 83
在 Spring Boot 中,yml 文件会优先于 properties 文件被加载。这是因为 Spring Boot 会优先使用 YAML 格式的配置文件,而 properties 文件只会在没有找到 YAML 格式的配置文件时使用。
相关问题
yaml yml properties文件加载顺序
1. 系统级配置文件:例如/etc/application.yml
2. 应用级配置文件:例如application.yml或application.properties
3. 外部配置文件:例如在启动时通过--spring.config.name或--spring.config.location指定的配置文件
4. 命令行参数:例如通过--server.port=8080指定的参数
5. 环境变量:例如通过环境变量SPRING_APPLICATION_JSON指定的JSON格式的配置
6. Java系统属性:例如通过-Dserver.port=8080指定的属性
7. 默认配置:例如Spring Boot内置的默认配置文件或者默认属性值
springboot的yml文件加载顺序
在Spring Boot中,加载yml文件的顺序如下:bootstrap (.yml 或者 .properties) -> application (.yml 或者 .properties) 。
更具体地说,加载顺序是:bootstrap.properties -> bootstrap.yml -> application.properties -> application.yml -> 具体的配置文件 -> 通用配置文件。
所以在一个文件夹中,先加载的是bootstrap.yml,然后是application.yml。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)