我需要创建一个使用 Akka 与一些外部应用程序通信的 Nutch 插件。为了做到这一点,我需要将插件打包为一个胖 Jar - 我使用的是sbt-assembly版本 0.8.3。
当我尝试运行插件时,出现异常
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'
好像阿卡找不到一样reference.conf
。这很奇怪,因为sbt-assembly
应该能够正确打包该文件,实际上我可以在创建的 jar 中看到它的内容。
我的build.sbt
样子是这样的:
import AssemblyKeys._
name := "my-project"
version := "0.1-SNAPSHOT"
scalaVersion := "2.10.0"
resolvers ++= Seq(
"Central Repo" at "http://repo1.maven.org/maven2",
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/",
"Akka io" at "http://akka.io/repository"
)
libraryDependencies ++= Seq(
...,
"com.typesafe.akka" %% "akka-actor" % "2.1.1",
"com.typesafe.akka" %% "akka-remote" % "2.1.1"
)
seq(assemblySettings: _*)
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case "plugin.xml" =>
MergeStrategy.first
case x if x startsWith "org/apache/jasper" =>
MergeStrategy.last
case x if x startsWith "javax/xml" =>
MergeStrategy.last
case x if x startsWith "javax/servlet" =>
MergeStrategy.last
case x if x startsWith "org/apache/commons" =>
MergeStrategy.last
case x if x startsWith "org/apache/xmlcommons" =>
MergeStrategy.last
case x if x startsWith "org/xml/sax" =>
MergeStrategy.last
case x if x startsWith "org/w3c/dom" =>
MergeStrategy.last
case x => old(x)
}
}
需要最后几行来解决 nutch 和 hadoop 之间的一些冲突。
打包 Akka 应用程序的正确方法是什么?