那什么是多環(huán)境開發(fā)?就是針對不同的環(huán)境設(shè)置不同的配置屬性即可。比如你自己開發(fā)時,配置你的端口如下:
?server: ? port: 80
如何想設(shè)計兩組環(huán)境呢?中間使用三個減號分隔開
?server: ? port: 80 ?--- ?server: ? port: 81
如何區(qū)分兩種環(huán)境呢?起名字唄
?spring: ? profiles: pro ?server: ? port: 80 ?--- ?spring: ? profiles: dev ?server: ? port: 81
在idea的配置文件中配置了這三個環(huán)境,下面的Document會顯示1or2or3/3
那用哪一個呢?設(shè)置默認啟動哪個就可以了
?#應(yīng)用環(huán)境 ?spring: ? profiles: ? active: pro # 啟動pro ?--- ?#生產(chǎn)環(huán)境 ?spring: ? profiles: pro ?server: ? port: 80 ?--- ?#開發(fā)環(huán)境 ?spring: ? profiles: dev ?server: ? port: 81
就這么簡單,再多來一組環(huán)境也OK
?spring: ? profiles: ? active: pro # 啟動pro ?--- ?spring: ? profiles: pro ?server: ? port: 80 ?--- ?spring: ? profiles: dev ?server: ? port: 81 ?--- ?spring: ? profiles: test ?server: ? port: 82
其中關(guān)于環(huán)境名稱定義上述格式是過時格式,標準格式如下(作用一樣)
spring: profiles:
和下面的一樣
?spring: ? config: ? ? activate: ? ? ? ? on-profile: pro
總結(jié)
-
多環(huán)境開發(fā)需要設(shè)置若干種常用環(huán)境,例如開發(fā)、生產(chǎn)、測試環(huán)境
-
yaml格式中設(shè)置多環(huán)境使用---區(qū)分環(huán)境設(shè)置邊界
-
每種環(huán)境的區(qū)別在于加載的配置屬性不同文章來源:http://www.zghlxwxcb.cn/news/detail-496350.html
-
啟用某種環(huán)境時需要指定啟動時使用該環(huán)境文章來源地址http://www.zghlxwxcb.cn/news/detail-496350.html
到了這里,關(guān)于【Springboot】什么是多環(huán)境開發(fā)?的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!