首先配置檔案:user.properties
初始demozhangsan=18
lisi=24
wangwu=26
tianqi=16
列印結果public
class
propertiesdemo
}}
![](https://pic.w3help.cc/0dc/19b5f33a15e7fa8f3f503bc9ff5b7.jpeg)
可以看到輸出的順序與配置檔案的順序不一致,因為properties繼承自hashtable,不能保證存放和拿取的順序一致。
廢話不多說,由於比較簡單,就直接上demo
建立customproperties
修改demopublic
class
customproperties
extends
properties
public map
getlinkedhashmap()
}
列印結果public
class
propertiesdemo
}}
![](https://pic.w3help.cc/b63/52ba27c847deb0d97800ee9303421.jpeg)
載入properties檔案
1 使用絕對路徑 string filename c a.properties properties p new properties inputstream input new fileinputstream filename p.load input 缺點 使用了絕對路徑,不利於專案的拷貝 頻繁...
properties載入順序
屬性多於乙個的話,mybatis按照如下的順序載入它們 1 在properties元素體內指定的屬性首先被讀取。2 從類路徑下資源或properties元素的url屬性中載入的屬性第二被讀取,它會 color red 覆蓋 color 已經存在的完全一樣的屬性。3 作為方法引數傳遞的屬性最後被讀取,...
載入properties檔案
載入properties檔案的方式有兩種 1 通過io流的方式來載入properties檔案 1 2 通過io流的方式來載入properties檔案3 4 throws exception5 6 test 7public void test1 throws exception 22 2 通過reso...