本篇文章給大家分享的是有關(guān)如何使springbootenviroment擁有PropertySource,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的蒼南網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
springboot 啟動(dòng)時(shí),屬性會(huì)被各種PropertySource加載,并把一系列的 PropertySource 按順序存放在 enviroment 中。我們在獲取屬性時(shí),通過enviroment.getProperty() 按照propertySource在List的順序獲取屬性值。
下圖是springboot 1.5.x的enviroment中的propertySourceList的值
下圖是springboot 2.1.x 的enviroment中的propertySourceList的值
可以看到,在2.x后,springboot 為enviroment 多注冊了 ConfigurationPropertySourcesPropertySource 。具體的代碼在 SpringApplication 類的 prepareEnvironment 方法中,springboot 2 使用
ConfigurationPropertySources.attach(environment);
給enviroment添加了 ConfigurationPropertySourcesPropertySource。
以上就是如何使springbootenviroment擁有PropertySource,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁題目:如何使springbootenviroment擁有PropertySource
網(wǎng)站URL:http://chinadenli.net/article26/giescg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、做網(wǎng)站、軟件開發(fā)、品牌網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、云服務(wù)器
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)