[英]how to set custom system variable for JVM to access properties file?
我需要從使用變量-Dapp.conf=/path/to/config.properties
設置的位置讀取config.properties
文件,並在啟動應用程序時將其設置為Datasource。 文件應位於文件系統內的任何位置。 這個怎么做?
您可以如下加載properties
文件:
Properties p = new Properties();
try (Reader reader = new FileReader(System.getProperty("app.conf"))) {
p.load(reader);
}
加載后,您可以使用properties
實例來設置數據源配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.