Spring Boot 的系统配置文件加载顺序

【理论介绍】

配置文件加载顺序:

1、项目根目录下的config目录。【优先级最高】
2、项目根目录。
3、classpath下的config目录。
4、classpath目录(新建项目时application.properties默认所在位置)。【优先级最低】

备注:
加载顺序:4 -> 3 -> 2 -> 1。
优先级:逐渐减低(1>2>3>4)。


【举例说明】

项目结构示例:

1、项目根目录下的config目录(file:./config/):helloworld/config/
2、项目根目录(file:./):helloworld/
3、classpath下的config目录(classpath:/config/):helloworld/src/main/resources/config/
4、classpath目录(classpath:/

猜你喜欢

转载自blog.csdn.net/Shipley_Leo/article/details/128174689
今日推荐