Scala未找到配置密钥

Scala未找到配置密钥,scala,Scala,我可以从中提取价值 val ranking_score_path = cf.getString(stg + ".input.path.ranking_score") .replaceAll("_replace_date_", this_date) 及 但不是 val AS_HOST = cf.getString(stg + ".output.path.aerospike.host") println("AS_HOST = " + AS_HOST) 我试过了 替换。与 添加逗号 但是没有起

我可以从中提取价值

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

但不是

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

  • 替换。与
  • 添加逗号
  • 但是没有起作用

    错误日志

    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"
          }
        }
      }
    }
    
    回复@Comment#1

    cf很长,但重要的部分如下

    ... ore.csv"}},"output":{"path":{"hdfs":"/user/aduser/dyson/display/","local":"/home/aduser/tmp/"}}},"sun":{"arch": ...
    
    努力#1:替换了应用程序的一部分。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)
    

    我在几个小时后发现了这个问题,我的application.conf与src.main.scala处于同一级别,并且由于我不知道的原因部分工作。在创建src.main.resources并将application.conf放入其中之后,它工作得非常好。

    Print/debug
    cf
    以检查可用键
    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)