简体   繁体   中英

ElasticSearch TransportClient version 5.6

I'm new in Elastisearch Java API

I installed the version 5.6 My server elasticsearch is runing in

http://localhost:9200/

 {
      "name" : "KJj0iv3",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "0je2mMloQ52X_GT1itxGuA",
      "version" : {
        "number" : "5.6.3",
        "build_hash" : "1a2f265",
        "build_date" : "2017-10-06T20:33:39.012Z",
        "build_snapshot" : false,
        "lucene_version" : "6.6.1"
      },
      "tagline" : "You Know, for Search"
    }

and this is my class Test Java

public static void main(String[] args) throws UnknownHostException {
    try {
        TransportClient client;

        client = new PreBuiltTransportClient(Settings.EMPTY)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9200));
        // on shutdown
        client.close();
    } catch (ElasticsearchException e) {
        System.out.println(e.getMessage());
    }
}

this is my error

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.debug(Ljava/lang/String;Ljava/lang/Object;)V
    at org.elasticsearch.threadpool.ThreadPool.<init>(ThreadPool.java:203)
    at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:129)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:265)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:130)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:116)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:106)
    at queryDsl.Test.main(Test.java:24)

在9200上改用端口9300,因为TransportClient在使用传输模块进行通信时需要端口9300。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM