java.lang.NoSuchMethodError: org.elasticsearch.action.support.master.AcknowledgedResponse

공식 강좌를 참고하다

            org.elasticsearch.client
            elasticsearch-rest-high-level-client
            7.2.0

package com.example.restclient;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import java.io.IOException;


public class DeleteIndex {
    static RestHighLevelClient client = new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("localhost", 9200, "http")));

    public static void main(String[] agrs) throws IOException {
        // 1、 
        DeleteIndexRequest request = new DeleteIndexRequest("test");
        // 2.  
        AcknowledgedResponse deleteIndexResponse = client.indices().delete(request, RequestOptions.DEFAULT);
        // 3、 
        boolean acknowledged = deleteIndexResponse.isAcknowledged();
        System.out.println("acknowledged = " + acknowledged);
        //4. RestHighLevelClient
        client.close();

    }
}


잘못 보고하여 방법을 찾지 못하다
Exception in thread "main" java.lang.NoSuchMethodError: org.elasticsearch.action.support.master.AcknowledgedResponse.fromXContent(Lorg/elasticsearch/common/xcontent/XContentParser;)Lorg/elasticsearch/action/support/master/AcknowledgedResponse;
	at org.elasticsearch.client.IndicesClient.delete(IndicesClient.java:97)
	at com.example.restclient.DeleteIndex.main(DeleteIndex.java:26)

국외 사용자도 유사한 오류를 만났다https://stackoverflow.com/questions/53755092/i-got-a-java-lang-nosuchmethoderror-when-using-deleteindexrequest
해결 방법,
의존도를 늘리면 된다
        
            org.elasticsearch
            elasticsearch
            7.2.0
        

보아하니 Elasticsearch 7.x의 공식 문서 구덩이는 여전히 매우 많다.

좋은 웹페이지 즐겨찾기