代码之家  ›  专栏  ›  技术社区  ›  suleydaman

如何引用scala工作表和akka中的配置文件?

  •  1
  • suleydaman  · 技术社区  · 8 年前

    我试图在scala工作表中创建一个简单的akka系统,但是每次我尝试时,都会得到这个错误。

    com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'
    at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(tsets.sc:148)
    at com.typesafe.config.impl.SimpleConfig.findKey(tsets.sc:141)
    at com.typesafe.config.impl.SimpleConfig.findOrNull(tsets.sc:168)
    at com.typesafe.config.impl.SimpleConfig.find(tsets.sc:180)
    at com.typesafe.config.impl.SimpleConfig.find(tsets.sc:185)
    at com.typesafe.config.impl.SimpleConfig.getString(tsets.sc:242)
    at akka.actor.ActorSystem$Settings.<init>(tsets.sc:166)
    at akka.actor.ActorSystemImpl.<init>(tsets.sc:533)
    at akka.actor.ActorSystem$.apply(tsets.sc:139)
    at akka.actor.ActorSystem$.apply(tsets.sc:116)
    at #worksheet#.system$lzycompute(tsets.sc:9)
    at #worksheet#.system(tsets.sc:9)
    at #worksheet#.get$$instance$$system(tsets.sc:9)
    at A$A9$.main(tsets.sc:35)
    at #worksheet#.#worksheet#(tsets.sc)
    

    即使scala工作表与 application.conf 文件。

    文件的akka条目看起来像这样。

    akka {
      loglevel = ??
      actor {
        provider = ??
     }
     remote {
    log-remote-lifecycle-events = ??
    enabled-transports =??
    netty.tcp {
      hostname = ??
      port = ??
      maximum-frame-size = ??
      maximum-frame-size = ??
      send-buffer-size = ??
      send-buffer-size = ??
      receive-buffer-size = ??
      receive-buffer-size = ??
    }
      }
    
      cluster {
    roles = ["frontend"]
    seed-nodes = ??
    use-dispatcher = c??
    
    failure-detector {
      threshold = ??
      acceptable-heartbeat-pause = ??
      heartbeat-interval = ??
      heartbeat-request {
        expected-response-after = ??
      }
      }
     }
    }
    

    我甚至尝试将此添加到构建中。

    assemblyMergeStrategy in assembly := {
      case PathList("application.conf") => MergeStrategy.concat
    }
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   Duelist    8 年前
    val confPath = getClass.getResource("/application.conf")
    val config = ConfigFactory.parseFile(new File(confPath.getPath)).resolve()
    config.getString("akka.loglevel")
    

    application.conf resources scala

    workaround

    enter image description here

    ConfigFactory.load()

    enter image description here

    推荐文章