错误:java.lang.NoSuchMethodError:com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava / util / concurrent / Executor;

时间:2017-01-12 20:17:39

标签: scala api elasticsearch concurrency

我得到错误,就像标题一样。我已经研究过了,发现了一些相似之处,但它并没有对我产生影响。

我使用Scala作为编程语言来创建API,使用Elasticsearch作为数据库。

这是我的代码 build.sbt

name := "LearningByDoing"

version := "1.0"

scalaVersion := "2.10.5"

resolvers += "spray repo" at "http://repo.spray.io"
resolvers += "spray nightlies repo" at "http://nightlies.spray.io"

libraryDependencies += "io.spray" % "spray-json_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-can_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-client_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-testkit_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-routing_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-http_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-httpx_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-util_2.10" % "1.3.2"
libraryDependencies += "io.spray" % "spray-can_2.10" % "1.3.2"

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.12"
libraryDependencies += "org.elasticsearch" % "elasticsearch" % "2.3.1"
libraryDependencies += "com.sksamuel.elastic4s" % "elastic4s-streams_2.10" % "2.3.1"
libraryDependencies += "org.elasticsearch" % "elasticsearch-mapper-attachments" % "2.3.1"
libraryDependencies += "com.typesafe" % "config" % "1.2.1"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.3.1"

这是我的代码 plugins.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0-M4") 
addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.3.9")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
在终端,我写的是 sbt clean编译测试更新包,一切正常。但是当我点击API时总会出现错误。

2 个答案:

答案 0 :(得分:0)

好像你有一些错误的番石榴版本,就像你提到的firs link一样,你可以使用this sbt插件看到依赖树,并找出一些混乱的依赖。

答案 1 :(得分:0)

问题是Elasticsearch的TCP客户端,因为5.0使用的是Netty 4.1,它与使用Netty 4的Spray不兼容。除了等待Spray升级或切换到elasticsearch HTTP客户端之外,没有其他解决方法。