springboot配置文件查找优先级

原创
2021/01/21 15:06
阅读数 194

spring boot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件

–file:.//
–file:./
–classpath:/config/
–classpath:/

但是寻找属性的优先级如下:

1、Command line arguments.
2、Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property).
3、ServletConfig init parameters.
4、ServletContext init parameters.
5、JNDI attributes from java:comp/env
6、Java System properties (System.getProperties()).
7、OS environment variables.
8、A RandomValuePropertySource that has properties only in random.*.
9、Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
10、Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
11、Application properties outside of your packaged jar (application.properties and YAML variants).
12、Application properties packaged inside your jar (application.properties and YAML variants).

 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部