在Elasticsearch 6上找不到org.elasticsearch.common.transport.InetSocketTransportAddress

问题描述 投票:11回答:1

我的代码在elasticsearch 5中工作得很好但是当我从5升级到6然后。它正在显示

org.elasticsearch.common.transport.InetSocketTransportAddress not found

完整的堆栈跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project elastic-store: Compilation failure
[ERROR] /home/elastic/elastic-store/src/main/java/com/qw/psence/store/es/common/ESClient.java:[12,42] cannot find symbol
[ERROR] symbol:   class InetSocketTransportAddress
[ERROR] location: package org.elasticsearch.common.transport
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]

任何人都可以帮我解决这个问题吗?

注意:Elasticsearch jar很好。

elasticsearch elasticsearch-5 elasticsearch-6
1个回答
26
投票

Elastic search 6.0已删除InetSocketTransportAddress类。我通过用TransportAddress类替换InetSocketTransportAddress类来解决这个问题。

// on startup

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));

// on shutdown

client.close();
© www.soinside.com 2019 - 2024. All rights reserved.