如何解决线程" main"中的异常com.typesafe.config.ConfigException $ Missing:没有为scala代码中的键""找到配置设置?

时间:2016-01-17 09:34:37

标签: java scala

我在scala中有一些代码:

def main(args: Array[String]): Unit = {
if (args.length < 1) {
  println("Must specify the path to config file ")
  println("Usage progname <path to config file> ")
  return
}
val url = args(0)
val config = ConfigFactory.load(url)
val host = config.getString(hostname)
val conf = new SparkConf(true).setAppName(appName)
  .set("spark.cassandra.connection.host", host)
val sc = new SparkContext(conf)

logger.info("Got the path as %s".format(url))
(sc, config)
.....
.....

但是当我试图运行时,出现以下错误:

 Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'MyTestCode'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:147)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:206)
at com.test.replicator.events.MyTestCode$.main(MyTestCode.scala:45)
at com.test.replicator.events.MyTestCode.main(MyTestCode.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

错误正在排队。

val host = config.getString(hostname)

如何解决问题。是Jar未找到问题还是代码错误?

0 个答案:

没有答案