方法不存在:org.elasticsearch.client.requestoptions $ builder.setRequestConfig(lorg/apache/http/client/client/config/requestconfig;)

发布于 2025-02-03 00:56:44 字数 1867 浏览 4 评论 0 原文

我正在创建带有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>

让我知道是否缺少某些内容。

I am creating Hibernate Search 6 application with Spring Boot 2.3.4

I am facing this error while I try to build my application -

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

Following are the dependencies that i have added -

        <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>

Let me know if I missing something.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

゛时过境迁 2025-02-10 00:56:44

这一切都在此处解释: https://docs.jboss.org/hibernate/stable/search/reference/reference/en-us/html_single/#gettingstarted-framework-framework-spring-spring-boot-boot-boot-depperency-verned-versency-versions

基本上,Spring Boot是管理您的依赖关系,并且正在迫使Elasticsearch客户端的较旧版本。您需要将其强制回到Hibernate搜索期望版本(一个较新的版本,7.16.x)。


只是为了澄清,这与我在其他答案中提到的Elasticsearch Server版本无关。这严格来说是关于您的客户的。

This is all explained here: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#gettingstarted-framework-spring-boot-dependency-versions

Basically, Spring Boot is managing your dependencies, and it's forcing an older version of the Elasticsearch client. You need to force it back to the version Hibernate Search expects (a newer version, 7.16.x).


And just to clarify, this has nothing to do with the Elasticsearch server version that I've seen mentioned in other answers. This is strictly about your client.

笑咖 2025-02-10 00:56:44

This is probably due to incompatible version of the elasticsearch dependency. From https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#getting-started-compatibility it seems you need 7.10 or 7.16 but you have 7.6 dependency. Also check server version to be sure.

放手` 2025-02-10 00:56:44

Hibernate-Search-Backend-elasticsearch

在内部取决于 elasticsearch-rest-client-7.6.2.jar

和该方法

org.elasticsearch.client.requestoptions $ builder.setRequestConfig(lorg/apache/http/client/client/configert/requestconfig;)lorg/elasticsearch/client/client/requestoptions $ builder;

它试图找到的是在低级客户端的以后版本中。

临时解决方案将排除7.6.2,并包含最新版本的 elasticsearch-rest-client-7.6.2.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>

由于这是临时的,我不确定这是否可靠。
如果有更好的解决方案,请让我知道。

hibernate-search-backend-elasticsearch

is internally dependent on elasticsearch-rest-client-7.6.2.jar

And the method

org.elasticsearch.client.RequestOptions$Builder.setRequestConfig(Lorg/apache/http/client/config/RequestConfig;)Lorg/elasticsearch/client/RequestOptions$Builder;

it is trying to find is in later versions of low level client.

Temporary solution will be to exclude 7.6.2 and include latest version of 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>

and including,

       <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>7.10.0</version>
        </dependency>

Since this is a temporary, I am not sure if this is reliable.
Please let me know in case there is a better solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文