1、獲取節點內的資訊(用於連線資料庫)
name="mydb" connectionstring="data source=192.168.253.31;initial catalog=dbname;user id=sa;pwd=******"
providername="system.data.sqlclient"
//winform程式讀取配置檔案
string constr=system.configuration.configurationmanager.connectionstrings["mydb"].connectionstring;
//web程式讀取配置檔案
string constr=system.web.configuration.webconfigurationmanager.connectionstrings["mydb"].connectionstring;
//讀取配置檔案
3、自定義配置檔案(沒有用過標記一下)
C 讀取配置檔案資訊
為了使 更加靈活,維護中不輕易動 配置檔案必不可少。下面就我在專案中寫的讀取配置檔案資訊分享給大家。name connection string connectionstring server database itsm0709 uid sa pwd 1 providername system.da...
SpringBoot讀取配置檔案資訊
其書寫風格為小數點間隔級別書寫全路徑。這個老 裡面見的比較多。示例如下 server.port 8080 spring.datasource.url jdbc mysql localhost 3306 demo spring.datasource.username root spring.datas...
SpringBoot讀取配置檔案資訊
用法如下,我們可以看到直接將environment注入進來,然後就可以使用getproperty方法來獲取配置的值了,引數是配置的名稱。我們獲取下之前配置的tomcat埠,http localhost 8090 config server.port可以看到輸出的結果正是你配置的值。restcontr...