java - java.lang.NoSuchMethodError: io.searchbox.action.Action.getURI()Ljava/lang/String
问题描述
在构建我的 Spring Boot 应用程序时出现错误。我正在使用 ES,当 jestClient 调用执行方法时出现错误。错误:
原因:org.springframework.beans.factory.BeanCreationException:创建名为“configService”的bean时出错:调用init方法失败;嵌套异常是 java.lang.NoSuchMethodError: io.searchbox.action.Action.getURI()Ljava/lang/String;
错误来自 jestHttpClient.class 的执行方法
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;
}
解决方案
这是一个常见错误,当您编译代码中引用的类的不同版本时会发生这种错误。这可能是因为您将依赖项导入了两次。
例如,您可以手动导入一个依赖项,该依赖项包含io.searchbox.action.Action
但io.searchbox.action.Action
也导入另一个版本的另一个依赖项中的依赖项。
只需注意您正在编译的版本,因为在 Jest 最新版本中 getURL 如下
String getURI(ElasticsearchVersion elasticsearchVersion);
但在 5.3.4 上如下
String getURI();
推荐阅读
- c# - 如何在 C# WPF 中创建一个可以与控件交互的完全自定义光标?
- linux - 使用 oci 堡垒服务连接到私有 kubernetes 集群时出错
- mysql - MySQL ...更新一个表,其中包含另一个表的值;多个条件
- ssl - SslHandler 的握手是否通过所有客户端/服务器管道处理程序?
- azure-functions - 多次调用 Azure 函数
- javascript - 想要从存在给定 accountId 的角色中获取数据。(Javascript, MongoDb)
- android-studio - 将 Unity Android 项目导入 Android Studio Wear OS 项目不让我点击完成按钮
- python - 如何在 Python 中处理循环依赖类
- azure - 将 Azure 托管的机器人添加到 Microsoft Teams 开发门户
- python - 如何在 Python 中修复我的比较测试?