gpt4 book ai didi

java - 由 : java. lang.ClassNotFoundException : org. elasticsearch.transport.Netty3Plugin 引起

转载 作者:搜寻专家 更新时间:2023-10-31 08:16:23 28 4
gpt4 key购买 nike

我正在使用 Spring Boot 2.0.3 版本,在实例化 org.elasticsearch.client.Client 时遇到问题。我的代码:

Client client = new PreBuiltTransportClient(Settings.builder()
.put("cluster.name", clustername)
.build())
.addTransportAddress(
new InetSocketTransportAddress(InetAddress.getByName(host), port)
);

这段代码给我错误:

Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/transport/Netty3Plugin
at org.elasticsearch.transport.client.PreBuiltTransportClient.<clinit>(PreBuiltTransportClient.java:91) ~[transport-5.6.10.jar:5.6.10]
at kz.icode.idmatrix.config.ElasticsearchConfiguration.client(ElasticsearchConfiguration.java:56) ~[classes/:na]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93.CGLIB$client$0(<generated>) ~[classes/:na]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93$$FastClassBySpringCGLIB$$fef36179.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringCGLIB$$7e53ae93.client(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 99 common frames omitted

我使用 org.elasticsearch:elasticsearch:5.6.10org.elasticsearch.client:client:5.6.10

最佳答案

并不是所有的依赖都通过添加 spring-boot-starter-data-elasticsearch 来满足.

有必要显式定义所有剩余的依赖项:

    <dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>

<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>

如果您已经声明了 parent ,很可能是 <version>标签可以省略。

关于java - 由 : java. lang.ClassNotFoundException : org. elasticsearch.transport.Netty3Plugin 引起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51039938/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com