我正在使用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.fig.ElasticsearchConfiguration.client(ElasticsearchConfiguration.java:56) ~[classes/:na]
at kz.icode.idmatrix.config.ElasticsearchConfiguration$$EnhancerBySpringcglib$$7e53ae93.cglib$client$0(fig.ElasticsearchConfiguration$$EnhancerBySpringcglib$$7e53ae93$$FastClassBySpringcglib$$fef36179.invoke(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(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.10和org.elasticsearch.client:client:5.6.10.
最佳答案
仅添加spring-boot-starter-data-elasticsearch并不能满足所有依赖项.
有必要明确定义所有剩余的依赖项:
如果您已声明父级,则很可能是< version>标签可以省略.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。