Elasticsearch TransportClient NetworkPlugin NoClassDefFoundError [英] Elasticsearch TransportClient NetworkPlugin NoClassDefFoundError
问题描述
@Configuration
public class ElasticsearchConfig {
私人TransportClient客户端;
@Bean
public TransportClient client()throws UnknownHostException {
设置设置= Settings.builder()
.put(client.transport
.put(client.transport.sniff,false)
.put(transport.tcp.compress,true)
.put(cluster .name,clusterName)
.put(xpack.security.transport.ssl.enabled,true)
.build();
client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(localhost),9300));
返回客户端;
}
当我启动项目我收到以下错误,我不知道为什么:
java.lang.ClassNotFoundException:org.elasticsearch.plugins.NetworkPlugin
/ pre>
我忘了添加依赖关系吗?
;依赖性>
< groupId> org.springframework.data< / groupId>
< artifactId> spring-data-elasticsearch< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.elasticsearch.client< / groupId>
< artifactId> transport< / artifactId>
< version> 5.1.1< / version>
< / dependency>
希望你能帮助我
解决方案我只是偶然发现同样的问题。似乎Elasticsearch文档不完整。除了运输客户端依赖,您还需要添加弹性搜索依赖关系:
< dependency>
< groupId> org.elasticsearch< / groupId>
< artifactId> elasticsearch< / artifactId>
< version> 5.1.1< / version>
< / dependency>
您还需要log4j依赖关系,但这在 Elasticsearch docs 。
I am looking forward to integrate Elasticsearch in a Spring Boot Web Application. Here is my configuration that creates my Transport Client:
@Configuration public class ElasticsearchConfig { private TransportClient client; @Bean public TransportClient client() throws UnknownHostException{ Settings settings = Settings.builder() .put("client.transport.nodes_sampler_interval", "5s") .put("client.transport.sniff", false) .put("transport.tcp.compress", true) .put("cluster.name", "clusterName") .put("xpack.security.transport.ssl.enabled", true) .build(); client = new PreBuiltTransportClient(settings); client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)); return client; }
When I start the Project I get following error and I don't know why:
java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPlugin
Did I forgot to add a dependency?
<dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-elasticsearch</artifactId> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> <version>5.1.1</version> </dependency>
Hope you can help me
解决方案I just stumbled over the same problem. Seems that the Elasticsearch docs aren't complete. In addition to the transport client dependency, you need to also add the elasticsearch dependency:
<dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>5.1.1</version> </dependency>
You'll also need the log4j dependency, but that is clearly stated in the Elasticsearch docs.
这篇关于Elasticsearch TransportClient NetworkPlugin NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!