ElasticSearch 6-TransportClient问题

时间:2018-10-16 13:18:08

标签: elasticsearch elasticsearch-5

我已经安装了ES 6.4.2,现在面临TransportClient的问题。考虑以下代码:

Settings settings = Settings.builder().put( "cluster.name", clustername ).put( "client.transport.ping_timeout", PING_TIMEOUT ).build();

Client client = new PreBuiltTransportClient( settings ).addTransportAddress( new TransportAddress( InetAddress.getByName( esHost ), port ) );

在pom中使用以下dep时:

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>6.4.2</version>
</dependency>

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>6.4.2</version>
</dependency> 

项目无法编译,并出现以下错误:     无法解析类型org.apache.lucene.util.Version。从所需的.class文件中间接引用了

在pom中使用6.1.2版本时,我能够运行项目,但是出现以下运行时错误:

Exception in thread "main" java.lang.NoClassDefFoundError: com/carrotsearch/hppc/IntSet
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:98)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:128)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:262)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:128)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:114)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:104)
at com.tests.simple.es.EsTemp.<init>(EsTemp.java:48)
at com.tests.simple.es.EsTemp.main(EsTemp.java:99)
Caused by: java.lang.ClassNotFoundException: com.carrotsearch.hppc.IntSet
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more

在我的类路径中找到了jar hppc-0.7.1.jar,但是IntSet似乎是抽象的。我可能做错了,任何帮助都值得赞赏。

0 个答案:

没有答案