一 內容總況
爲什麼使用yml文件?和學習yml語法。
SpringBoot的配置文件有兩種,一種是properties結尾的,另一種是yml文件結尾的。
1.application.properties
2.application.yml
默認情況下是properties結尾的配置文件
配置文件放在src/resources目錄或者類路徑/config/下
二 先弄清什麼是yml文件?
yml是YAML(YAML Ain’t Markup Language)語言的文件,以數據爲中心,比json。xml文件更適合做配置文件。
三 對比區別
properties
結尾的配置文件內容
server.port=9090
luyz.msg=hi,hello world!!!!!!!!!
轉化爲yml
配置文件
server:
port: 9090
luyz:
msg: hi,hello world!!!!!!!!!
注意:以空格的縮進程度開控制層級關係。(空格的多少不重要)
四、推薦
SpringBoot系列剛剛開始,後續會持續更新,謝謝關注。