讀取properties配置檔案中屬性的值的工具類

2021-08-20 09:36:24 字數 624 閱讀 3031

專案中常用的一些配置的維護,例如redis的ip,資料庫ip這些一點是用檔案維護起來,方便專案開發時進行除錯,為了方便以後使用,就直接封裝了乙個工具類以便使用,**如下:

/**

* 讀取properties配置檔案中屬性的值的工具類

*@author zzx

*/public

class

readpropertiesutils

/*** 讀取properties配置檔案中屬性的值

*@param resourcelocation 檔名 比如:classpath:shopxx.properties

*@param resourcename 資源名

*@return

*/public

static string getattrvalue(string resourcelocation, string resourcename) catch (ioexception e)

string attributevalue = properties.getproperty(resourcename);

return attributevalue;

}}

大概就是如此~

mybatis讀取properties檔案內容

今天在mybatis中想讀取檔案內容,一開始是建立的xml檔案,發現必須要表頭,不然就是 完全不適用,然後突然靈光一現,可以建立properties檔案,讀取檔案,通過鍵值對獲取內容。properties proper new properties proper.load this.getclass...

java sdk讀取properties檔案

獲得properties檔案中key為classname的值 resourcebundle bundle resourcebundle.getbundle data 通過getbundle獲得src下properties檔案 檔名為data.properties 獲得值 string classna...

python讀取properties配置檔案並解析

ld.properties 配置資訊 database.type argo database.name dd database.ip 10.12.15.225 database.port 10000 database.username user database.password passwd pr...