当前位置: 首页 > 知识库问答 >
问题:

从maven项目连接到弹性搜索的问题

谢墨竹
2023-03-14

在我的maven-Spring项目中,我试图以以下身份连接到ElasticSearch:TransportClient esclient=TransportClient.builder().build().AddTransportAddress(new InetSocketTransportAddress(InetAddress.GetByName(“localHost”),9300));

我不断得到:servlet.service()for servlet dispatcher抛出异常java.lang.NoSuchMethoderRror:com.google.common.util.concurrent.MoreExecutors.DirectExecutor()ljava/util/concurrent/executor;在org.elasticsearch.threadpool.threadpool.(threadpool.java:192)在org.elasticsearch.client.transport.transportclient$builder.build(transportclient.java:133)在com.controller.appcontroller.loginpage(appcontroller.java:204)在sun.reflect.nativeMethodAccessorImpl.Invoke0(原生方法)在sun.reflect.nativeMethodAccessorImpl.java:62)在sun.reflect.delegatingmethodAccessorImpl.Invoke(delegatingmethodAccessorImpl.java:498)在framework.web.Method.support.InvocableHandlerMethod.DoInvoke(InvocableHandlerMethod.java:221)

为了消除这个异常:我尝试添加Guava18.0依赖项,在org.elasticsearch中添加排除项,并为maven添加阴影Guava。

在不添加番石榴依赖项或排除项的情况下,这是我的依赖项:树

--- maven-dependency-plugin:2.6:tree (default-cli) ---
com.spring.mvc:App:war:1.0-SNAPSHOT
+- javax:javaee-web-api:jar:7.0:provided
+- org.springframework:spring-core:jar:4.2.5.RELEASE:compile
|  \- commons-logging:commons-logging:jar:1.2:compile
+- org.springframework:spring-web:jar:4.2.5.RELEASE:compile
|  +- org.springframework:spring-aop:jar:4.2.5.RELEASE:compile
|  +- org.springframework:spring-beans:jar:4.2.5.RELEASE:compile
|  \- org.springframework:spring-context:jar:4.2.5.RELEASE:compile
+- org.springframework:spring-webmvc:jar:4.2.5.RELEASE:compile
|  \- org.springframework:spring-expression:jar:4.2.5.RELEASE:compile
+- org.springframework:spring-tx:jar:4.2.5.RELEASE:compile
+- org.springframework:spring-orm:jar:4.2.5.RELEASE:compile
|  \- org.springframework:spring-jdbc:jar:4.2.5.RELEASE:compile
+- org.springframework.security:spring-security-web:jar:4.0.4.RELEASE:compile
|  +- aopalliance:aopalliance:jar:1.0:compile
|  \- org.springframework.security:spring-security-core:jar:4.0.4.RELEASE:compile
+- org.springframework.security:spring-security-config:jar:4.0.4.RELEASE:compile
+- org.springframework.security:spring-security-taglibs:jar:4.0.4.RELEASE:compile
|  \- org.springframework.security:spring-security-acl:jar:4.0.4.RELEASE:compile
+- org.hibernate:hibernate-core:jar:4.3.11.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
|  +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
|  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
|  +- dom4j:dom4j:jar:1.6.1:compile
|  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
|  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
|  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
|  +- org.javassist:javassist:jar:3.18.1-GA:compile
|  +- antlr:antlr:jar:2.7.7:compile
|  \- org.jboss:jandex:jar:1.1.0.Final:compile
+- javax.validation:validation-api:jar:1.1.0.Final:compile
+- org.hibernate:hibernate-validator:jar:5.1.3.Final:compile
|  \- com.fasterxml:classmate:jar:1.0.0:compile
+- mysql:mysql-connector-java:jar:5.1.31:compile
+- ch.qos.logback:logback-classic:jar:1.1.7:compile
|  +- ch.qos.logback:logback-core:jar:1.1.7:compile
|  \- org.slf4j:slf4j-api:jar:1.7.20:compile
+- javax.servlet:javax.servlet-api:jar:3.1.0:compile
+- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:compile
+- javax.servlet:jstl:jar:1.2:compile
\- org.elasticsearch:elasticsearch:jar:2.4.5:compile
   +- org.apache.lucene:lucene-core:jar:5.5.4:compile
   +- org.apache.lucene:lucene-backward-codecs:jar:5.5.4:compile
   +- org.apache.lucene:lucene-analyzers-common:jar:5.5.4:compile
   +- org.apache.lucene:lucene-queries:jar:5.5.4:compile
   +- org.apache.lucene:lucene-memory:jar:5.5.4:compile
   +- org.apache.lucene:lucene-highlighter:jar:5.5.4:compile
   +- org.apache.lucene:lucene-queryparser:jar:5.5.4:compile
   |  \- org.apache.lucene:lucene-sandbox:jar:5.5.4:compile
   +- org.apache.lucene:lucene-suggest:jar:5.5.4:compile
   |  \- org.apache.lucene:lucene-misc:jar:5.5.4:compile
   +- org.apache.lucene:lucene-join:jar:5.5.4:compile
   |  \- org.apache.lucene:lucene-grouping:jar:5.5.4:compile
   +- org.apache.lucene:lucene-spatial:jar:5.5.4:compile
   |  +- org.apache.lucene:lucene-spatial3d:jar:5.5.4:compile
   |  \- com.spatial4j:spatial4j:jar:0.5:compile
   +- com.google.guava:guava:jar:18.0:compile
   +- org.elasticsearch:securesm:jar:1.0:compile
   +- com.carrotsearch:hppc:jar:0.7.1:compile
   +- joda-time:joda-time:jar:2.9.5:compile
   +- com.fasterxml.jackson.core:jackson-core:jar:2.8.1:compile
   +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.1:compile
   +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.8.1:compile
   +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.1:compile
   +- org.yaml:snakeyaml:jar:1.15:compile
   +- io.netty:netty:jar:3.10.6.Final:compile
   +- com.ning:compress-lzf:jar:1.0.2:compile
   +- com.tdunning:t-digest:jar:3.0:compile
   +- org.hdrhistogram:HdrHistogram:jar:2.1.6:compile
   +- commons-cli:commons-cli:jar:1.3.1:compile
   \- com.twitter:jsr166e:jar:1.1.0:compile

共有1个答案

云欣嘉
2023-03-14

在查看更多内容时,我发现GlassFish自身的依赖项泄漏到应用程序类路径中(而GF使用的是较旧的Guava),因此GlassFish 4.1用户的修复方法是用Guava 19版本更新/glassFish/modules中的Guava.jar。

<dependency>
    <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
    <artifactId>jersey-guava</artifactId>
    <version>2.19</version>
</dependency>
 类似资料:
  • 我目前正在运行elastic search和kibana 7.0.0版,在我的项目中有一个docker compose文件 我能够连接到端口5601上的kibana(索引和搜索数据),以及端口9200上的弹性搜索。 我试图使用NEST连接到弹性这里是我的基本配置 当我通过NEST执行任何命令时,如ping、健康检查或搜索等,我检索到以下异常。这让我相信docker容器(linux容器)中存在一些与

  • 我通过弹性搜索访问了上市公司数据库的单向导出功能。我在R和弹性包装的连接上有问题。 我有服务器名称(URL)、用户名和密码,但我没有任何端口号。他们将其描述为rest API。我必须使用弹性包吗?或者有更简单的方法来解决它。我对数据库的唯一信息是:http://distribution.virk.dk/cvr-permanent/virksomhed/_search?. 上面的链接适用于HTTR,

  • 我在localhost:9200上有一个本地弹性搜索,当我向浏览器输入地址时,我得到了以下内容: 当我尝试运行我的应用程序时,我得到以下错误: 如何用我的Jhipster(V5.0.0-beta.3)后端连接到这个弹性服务器?

  • 我正在尝试创建一个节点。带有RESTAPI的js应用程序,用于查询弹性搜索应用程序云上的数据。我有以下elasticsearch连接代码 上面的连接连接正确,如果我添加任何数据,它也会被添加。但是我希望数据不会被添加到本地主机。我希望我的实际集群拥有数据。我尝试了以下代码 上面的代码仍然没有添加数据或从我的云集群中检索数据... Evrry在互联网上我只找到localhost示例...有人能告诉我

  • 我使用Elasticsearch允许用户输入要搜索的术语。例如,我要搜索以下属性'name': 如果使用以下代码搜索或,我希望返回此文档。 我尝试过做一个bool must和做多个术语,但它似乎只有在整个字符串都匹配的情况下才起作用。 所以我真正想做的是,这个词是否以任何顺序包含两个词。 有人能帮我走上正轨吗?我已经在这上面砸了一段时间了。

  • 我有两个弹性搜索服务器,我需要添加到spring boot项目的连接。对于一个连接,下面是我的代码, 那么如何添加其他服务器连接呢?如果我复制这个类并添加其他服务器连接详细信息,它会起作用吗?而且我还需要分隔索引。例如,我需要索引必须仅在中,并且索引必须仅在中。这可能吗?如果有人能帮助我,真的很感激。