Elastic4s java.lang.NoSuchMethodError
Elastic4s java.lang.NoSuchMethodError
我正在尝试通过 Elastic4s 连接到 ES 集群。我正在使用 github 存储库中给出的示例:
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
object Test extends App {
val client = ElasticClient.transport(ElasticsearchClientUri(host, port))
// await is a helper method to make this operation synchronous instead of async
// You would normally avoid doing this in a real program as it will block your thread
client.execute { index into "bands" / "artists" fields "name"->"coldplay" }.await
// we need to wait until the index operation has been flushed by the server.
// this is an important point - when the index future completes, that doesn't mean that the doc
// is necessarily searchable. It simply means the server has processed your request and the doc is
// queued to be flushed to the indexes. Elasticsearch is eventually consistent.
// For this demo, we'll simply wait for 2 seconds (default refresh interval is 1 second).
Thread.sleep(2000)
// now we can search for the document we indexed earlier
val resp = client.execute { search in "bands" / "artists" query "coldplay" }.await
println(resp)
}
客户端按照此处所述在 9434 上接受连接 - https://www.elastic.co/guide/en/cloud/current/security.html#security-transport
此外,它会根据选择的构造方式查找或附加 - elasticsearch:\
到主机和端口。
在 运行 之后,即使是初始化客户端的行,我也得到了 Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)[Ljava/lang/Object;
显然我误会了什么。请让我知道我做错了什么。
编辑:
作为验证,我有一个使用常规 http 连接的 ES .Net 客户端。
var node = new Uri(url);
var connectionSettings = new ConnectionSettings(node);
connectionSettings.BasicAuthentication(settings.username,settings.password);
client = new ElasticClient(connectionSettings);
我的目标是实现同样的目标。
这似乎是您的依赖项中缺少 scala 库。因此,根据您使用的 Scala 版本,您必须让您的部门匹配该版本。您使用的是什么构建工具?
SBT(您不需要这样做,SBT 应该根据您的 scalaVersion 自动执行)
"org.scala-lang" % "scala-library" % "YOUR SCALA VERSION"
行家
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.1</version>
</dependency>
SBT这里也有一些资料,http://www.scala-sbt.org/1.0/docs/Configuring-Scala.html
我正在尝试通过 Elastic4s 连接到 ES 集群。我正在使用 github 存储库中给出的示例:
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
object Test extends App {
val client = ElasticClient.transport(ElasticsearchClientUri(host, port))
// await is a helper method to make this operation synchronous instead of async
// You would normally avoid doing this in a real program as it will block your thread
client.execute { index into "bands" / "artists" fields "name"->"coldplay" }.await
// we need to wait until the index operation has been flushed by the server.
// this is an important point - when the index future completes, that doesn't mean that the doc
// is necessarily searchable. It simply means the server has processed your request and the doc is
// queued to be flushed to the indexes. Elasticsearch is eventually consistent.
// For this demo, we'll simply wait for 2 seconds (default refresh interval is 1 second).
Thread.sleep(2000)
// now we can search for the document we indexed earlier
val resp = client.execute { search in "bands" / "artists" query "coldplay" }.await
println(resp)
}
客户端按照此处所述在 9434 上接受连接 - https://www.elastic.co/guide/en/cloud/current/security.html#security-transport
此外,它会根据选择的构造方式查找或附加 - elasticsearch:\
到主机和端口。
在 运行 之后,即使是初始化客户端的行,我也得到了 Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)[Ljava/lang/Object;
显然我误会了什么。请让我知道我做错了什么。
编辑:
作为验证,我有一个使用常规 http 连接的 ES .Net 客户端。
var node = new Uri(url);
var connectionSettings = new ConnectionSettings(node);
connectionSettings.BasicAuthentication(settings.username,settings.password);
client = new ElasticClient(connectionSettings);
我的目标是实现同样的目标。
这似乎是您的依赖项中缺少 scala 库。因此,根据您使用的 Scala 版本,您必须让您的部门匹配该版本。您使用的是什么构建工具?
SBT(您不需要这样做,SBT 应该根据您的 scalaVersion 自动执行)
"org.scala-lang" % "scala-library" % "YOUR SCALA VERSION"
行家
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.1</version>
</dependency>
SBT这里也有一些资料,http://www.scala-sbt.org/1.0/docs/Configuring-Scala.html