[英]Check if there is no application.conf
如何檢查我的Spark應用程序是否沒有application.conf?
我讀了這個會議與:
Config configuracion = ConfigFactory.load();
但是當我檢查時:
if (null != configuracion && !configuracion.isEmpty() && !configuracion.entrySet().isEmpty()){
config_exists = true;
}
它總是返回config_exists = true。
謝謝!!
問題在於ConfigFactory.load()
加載系統屬性。 因此,生成的Config
對象不為空。
我為您准備了駭客,也許有一種我不知道的簡單方法。
Config conf = ConfigFactory.load();
// create a config containing only the system properties
Config emptyConfig = ConfigFactory.systemProperties();
// check that the loaded config is not equal to this "empty config"
Boolean isDefinedConfig = ! conf.equals(emptyConfig);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.