web-dev-qa-db-ja.com

org.elasticsearch.common.transport.InetSocketTransportAddressがElasticsearch 6に見つかりません

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]

誰でもこの問題を解決するのを手伝ってくれますか?

注:Elaticsearch jarは問題ありません。

14
Arayan Singh

Elastic Search 6.0は、InetSocketTransportAddressクラスを削除しました。 InetSocketTransportAddress classをTransportAddress classに置き換えることでこれを解決しました。

// 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();
28
Arayan Singh

この問題には多くの解決策がありますが、SpringBootで基本的なelasticsearch構成を作成しようとしていたため、このエラーが発生していました。

elasticsearchを開始するのを忘れた...

:facepalm:

これだけ:

  1. elasticsearchインストールディレクトリのbinフォルダーでコマンドラインを開きます*
  2. タイプelasticsearch
  3. enterを押す

機能することを確認するには、http://localhost:9200/ブラウザで。名前、cluster_name、elasticsearchバージョンなどを含むJSON応答を取得する必要があります。

*(Windowsの場合)ES_INSTALLATION_DIR\elasticsearch-x.x.x\binフォルダー、Shiftキーを押しながらフォルダー領域を右クリックし、ドロップダウンメニューからOpen command window here

0
Filip Savic