2017-08-05 44 views
-1

我能爲斯卡拉無需配置鑰匙上發現

val ranking_score_path = cf.getString(stg + ".input.path.ranking_score") 
    .replaceAll("_replace_date_", this_date) 

val output_path = cf.getString(stg + ".output.path.hdfs") + tomz_date + "/" 

但不

val AS_HOST = cf.getString(stg + ".output.path.aerospike.host") 
println("AS_HOST = " + AS_HOST) 

我已經試過

  1. 代表中獲取價值花邊。與_,
  2. 加逗號

但沒有工作。

錯誤日誌

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'production.output.path.aerospike' 
    at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152) 
    at ... 

application.conf

production { 
    input { 
    path { 
     local = "/home/aduser/tmp/" 
     hdfs = "/user/aduser/tmp_vincent/CPA/_replace_date_/intermediate/l1/" 
     ranking_score = "/home/aduser/plt/item_performance/pipeline/cpa/output/_replace_date_/predict_output/ranking_score.csv" 
    } 
    } 
    output { 
    path { 
     local = "/home/aduser/tmp/" 
     hdfs = "/user/aduser/dyson/display/" 
     aerospike { 
     host = "0.0.0.0" 
     port = 3000 
     namespace = "test" 
     set = "spark-test2" 
     } 
    } 
    } 
} 

回覆@註釋#1

比照很長,但重要的部分是如下

... ore.csv"}},"output":{"path":{"hdfs":"/user/aduser/dyson/display/","local":"/home/aduser/tmp/"}}},"sun":{"arch": ... 

努力#1:取代了application.conf

path { 
      local = "/home/aduser/tmp/" 
      hdfs = "/user/aduser/dyson/display/" 
      ae_host = "0.0.0.0" 
      ae_port = 3000 
      ae_namespace = "test" 
      ae_set = "spark-test2" 
     } 

的一部分,改變了調用方法

val AS_HOST = cf.getString(stg + ".output.path.ae_host") 
println("AS_HOST = " + AS_HOST) 

,但仍然得到錯誤

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'production.output.path.ae_host' 
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152) 
+0

打印/調試'cf'來檢查可用密鑰 – cchantep

回答

0

我已經找到了問題幾個小時後,我的application.conf與src.main.scala處於同一級別,並且部分工作我不知道的原因。它在創建src.main.resources並將application.conf放入其中之後完美運行。