java.lang.NoSuchMethodError:io.searchbox.action.Action.getURI()Ljava / lang / String

时间:2019-10-18 08:11:15

标签: java spring-boot elasticsearch kubernetes jest

构建Spring Boot应用程序时出现错误。我正在使用ES,并且jestClient调用execute方法时出现错误。 错误:

由以下原因引起:org.springframework.beans.factory.BeanCreationException:创建名称为'configService'的bean时出错:调用init方法失败;嵌套的异常是java.lang.NoSuchMethodError:io.searchbox.action.Action.getURI()Ljava / lang / String;

错误来自jestHttpClient.class的execute方法

public <T extends JestResult> T execute(Action<T> clientRequest, RequestConfig requestConfig) throws IOException {
    HttpUriRequest request = this.prepareRequest(clientRequest, requestConfig);
    CloseableHttpResponse response = null;

    JestResult var5;
    try {
        response = this.executeRequest(request);
        var5 = this.deserializeResponse(response, request, clientRequest);
    } catch (HttpHostConnectException var14) {
        throw new CouldNotConnectException(var14.getHost().toURI(), var14);
    } finally {
        if (response != null) {
            try {
                response.close();
            } catch (IOException var13) {
                log.error("Exception occurred while closing response stream.", var13);
            }
        }

    }

    return var5;

}

1 个答案:

答案 0 :(得分:0)

这是一个常见的错误,当您在代码中引用该类的另一个版本时,会发生该错误。发生这种情况是因为您两次导入了依赖项。

例如,您可以手动导入包含io.searchbox.action.Action的依赖项,但是io.searchbox.action.Action也将导入另一个版本的另一个依赖项中的一个依赖项中。

请注意要编译的版本,因为在最新的Jest版本中,getURL如下

String getURI(ElasticsearchVersion elasticsearchVersion);

但是在5.3.4中如下所示

String getURI();