我正在使用 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>
如果我遺漏了什么,請告訴我。
uj5u.com熱心網友回復:
這一切都在這里解釋:https ://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#gettingstarted-framework-spring-boot-dependency-versions
基本上,Spring Boot 正在管理您的依賴項,它強制使用舊版本的 Elasticsearch 客戶端。您需要將其強制恢復為 Hibernate Search 期望的版本(較新的版本,7.16.x)。
澄清一下,這與我在其他答案中提到的 Elasticsearch 服務器版本無關。這完全與您的客戶有關。
uj5u.com熱心網友回復:
這可能是由于 elasticsearch 依賴項的版本不兼容。從https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#getting-started-compatibility看來您需要 7.10 或 7.16 但您有 7.6 依賴項。還要檢查服務器版本以確保。
uj5u.com熱心網友回復:
休眠搜索后端彈性搜索
內部依賴于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>
由于這是暫時的,我不確定這是否可靠。如果有更好的解決方案,請告訴我。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/484795.html
