【理論介紹】
配置文件加載順序:
1、項(xiàng)目根目錄下的config目錄?!緝?yōu)先級最高】
2、項(xiàng)目根目錄。
3、classpath下的config目錄。
4、classpath目錄(新建項(xiàng)目時(shí)application.properties默認(rèn)所在位置)。【優(yōu)先級最低】
備注:
加載順序:4 -> 3 -> 2 -> 1。
優(yōu)先級:逐漸減低(1>2>3>4)。
【舉例說明】
項(xiàng)目結(jié)構(gòu)示例:
文章來源:http://www.zghlxwxcb.cn/news/detail-486817.html
1、項(xiàng)目根目錄下的config目錄(file:./config/):helloworld/config/
2、項(xiàng)目根目錄(file:./):helloworld/
3、classpath下的config目錄(classpath:/config/):helloworld/src/main/resources/config/
4、classpath目錄(classpath:/文章來源地址http://www.zghlxwxcb.cn/news/detail-486817.html
到了這里,關(guān)于Spring Boot 的系統(tǒng)配置文件加載順序的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!