方法不存在:org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)
Method does not exist: org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)
我正在使用 Spring Boot 2.3.4
创建 Hibernate Search 6 应用程序
我在尝试构建我的应用程序时遇到此错误 -
Description:
An attempt was made to call a method that does not exist. The attempt was made from the
following location:
org.hibernate.search.backend.elasticsearch.client.impl.ElasticsearchClientImpl.setPerRequestSocketTimeout(ElasticsearchClientImpl.java:198)
The following method did not exist:
org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)Lorg/elasticsearch/client/RequestOptions$Builder;
The method's class, org.elasticsearch.client.RequestOptions$Builder, is available from the following locations:
jar:file:/C:/Users/pranali.rasal/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar!/org/elasticsearch/client/RequestOptions$Builder.class
The class hierarchy was loaded from the following locations:
org.elasticsearch.client.RequestOptions.Builder:
file:/C:/Users/pranali.rasal/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RequestOptions$Builder
以下是我添加的依赖项-
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<version>6.1.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-elasticsearch</artifactId>
<version>6.1.5.Final</version>
</dependency>
如果我遗漏了什么,请告诉我。
这可能是由于 elasticsearch 依赖项的版本不兼容。从 https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#getting-started-compatibility 看来您需要 7.10 或 7.16,但您有 7.6 依赖项。还要检查服务器版本以确保。
hibernate-search-backend-elasticsearch
内部依赖于elasticsearch-rest-client-7.6.2.jar
和方法
org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)Lorg/elasticsearch/client/RequestOptions$Builder;
正在尝试在低级别客户端的更高版本中查找。
临时解决方案是排除 7.6.2 并包括最新版本 elasticsearch-rest-client-7.6.2.jar -
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-elasticsearch</artifactId>
<exclusions>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
</exclusions>
</dependency>
并包括,
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.10.0</version>
</dependency>
临时的,不知道靠谱不。
如果有更好的解决方案,请告诉我。
基本上,Spring Boot 正在管理您的依赖项,它会强制使用旧版本的 Elasticsearch 客户端。您需要强制它回到 Hibernate Search 期望的版本(较新的版本,7.16.x)。
澄清一下,这与我在其他答案中提到的 Elasticsearch 服务器版本无关。这完全是关于您的客户的。
我正在使用 Spring Boot 2.3.4
创建 Hibernate Search 6 应用程序我在尝试构建我的应用程序时遇到此错误 -
Description:
An attempt was made to call a method that does not exist. The attempt was made from the
following location:
org.hibernate.search.backend.elasticsearch.client.impl.ElasticsearchClientImpl.setPerRequestSocketTimeout(ElasticsearchClientImpl.java:198)
The following method did not exist:
org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)Lorg/elasticsearch/client/RequestOptions$Builder;
The method's class, org.elasticsearch.client.RequestOptions$Builder, is available from the following locations:
jar:file:/C:/Users/pranali.rasal/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar!/org/elasticsearch/client/RequestOptions$Builder.class
The class hierarchy was loaded from the following locations:
org.elasticsearch.client.RequestOptions.Builder:
file:/C:/Users/pranali.rasal/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RequestOptions$Builder
以下是我添加的依赖项-
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<version>6.1.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-elasticsearch</artifactId>
<version>6.1.5.Final</version>
</dependency>
如果我遗漏了什么,请告诉我。
这可能是由于 elasticsearch 依赖项的版本不兼容。从 https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#getting-started-compatibility 看来您需要 7.10 或 7.16,但您有 7.6 依赖项。还要检查服务器版本以确保。
hibernate-search-backend-elasticsearch
内部依赖于elasticsearch-rest-client-7.6.2.jar
和方法
org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)Lorg/elasticsearch/client/RequestOptions$Builder;
正在尝试在低级别客户端的更高版本中查找。
临时解决方案是排除 7.6.2 并包括最新版本 elasticsearch-rest-client-7.6.2.jar -
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-elasticsearch</artifactId>
<exclusions>
<exclusion>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
</exclusion>
</exclusions>
</dependency>
并包括,
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.10.0</version>
</dependency>
临时的,不知道靠谱不。 如果有更好的解决方案,请告诉我。
基本上,Spring Boot 正在管理您的依赖项,它会强制使用旧版本的 Elasticsearch 客户端。您需要强制它回到 Hibernate Search 期望的版本(较新的版本,7.16.x)。
澄清一下,这与我在其他答案中提到的 Elasticsearch 服务器版本无关。这完全是关于您的客户的。