首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图调用一个不存在的方法.修正类路径

试图调用一个不存在的方法.修正类路径
EN

Stack Overflow用户
提问于 2020-10-30 12:26:13
回答 1查看 1.2K关注 0票数 1

在尝试用spring引导将应用程序从2.1.8更新为2.3.4时,我设法解决了一些错误并成功地构建了该应用程序,但是在尝试运行主应用程序之后,下面的错误消息一直在扼杀我

代码语言:javascript
复制
***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClientFactory.createClient(DefaultElasticsearchClientFactory.java:92)

The following method did not exist:

    org.elasticsearch.client.RestClientBuilder.setMaxRetryTimeoutMillis(I)Lorg/elasticsearch/client/RestClientBuilder;

The org.elasticsearch.client.RestClientBuilder, is available from the following locations:

    jar:file:/Users/pei/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar!/org/elasticsearch/client/RestClientBuilder.class

The hierarchy was loaded from the following locations:

    org.elasticsearch.client.RestClientBuilder: file:/Users/pei/.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.RestClientBuilder


Process finished with exit code 1

我做了很多研究,包括this SO question和很多类似的案例,但我发现它们最终是不同的。例如,在我的案例中,似乎只有一个位置提供method class../mvnw dependency:tree -Pwar | grep elasticsearch的结果给出了

代码语言:javascript
复制
[INFO] +- org.hibernate:hibernate-search-elasticsearch:jar:5.11.2.Final:compile
[INFO] |  +- org.elasticsearch.client:elasticsearch-rest-client:jar:7.6.2:compile
[INFO] |  +- org.elasticsearch.client:elasticsearch-rest-client-sniffer:jar:5.6.8:compile
[INFO] +- org.elasticsearch.plugin:analysis-icu:jar:5.0.0-alpha5:test
[INFO] +- org.elasticsearch.plugin:analysis-kuromoji:jar:5.0.0-alpha5:test

我假设elasticsearch-rest-clientelasticsearch-rest-client-sniffer是两种不同的依赖关系,所以它们不是相互冲突的吗?

编辑:

在我添加了@gowridev的注释所建议的以下依赖项之后

代码语言:javascript
复制
<dependency>
    <groupId>org.hibernate.search</groupId>
    <artifactId>hibernate-search-backend-elasticsearch</artifactId>
    <version>6.0.0.Beta3</version>
</dependency>

错误保持不变,但变化不大。

代码语言:javascript
复制
***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.<clinit>(HibernateSearchSessionFactoryObserver.java:37)

The following method did not exist:

    org.hibernate.search.engine.Version.touch()V

The methods clas, org.hibernate.search.engine.Version, is available from the following locations:

    jar:file:/Users/pei/.m2/repository/org/hibernate/search/hibernate-search-engine/6.0.0.Beta3/hibernate-search-engine-6.0.0.Beta3.jar!/org/hibernate/search/engine/Version.class
    jar:file:/Users/pei/.m2/repository/org/hibernate/hibernate-search-engine/5.11.2.Final/hibernate-search-engine-5.11.2.Final.jar!/org/hibernate/search/engine/Version.class

The clas hierarchy was loaded from the following locations:

    org.hibernate.search.engine.Version: file:/Users/pei/.m2/repository/org/hibernate/search/hibernate-search-engine/6.0.0.Beta3/hibernate-search-engine-6.0.0.Beta3.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version


Process finished with exit code 1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-02 06:48:04

结果,我误解了错误信息。

代码语言:javascript
复制
Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version

在搜索此消息时,其他人在不同地方重复使用依赖关系时大多会遇到问题。这让我觉得我的理由是一样的。不是这样的。

关键不是版本不是单一,而是它不是与兼容的

简单地说,

代码语言:javascript
复制
org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClientFactory.createClient()

此方法正在调用

代码语言:javascript
复制
org.elasticsearch.client.RestClientBuilder.setMaxRetryTimeoutMillis()

但正如错误信息所指出的,它并不存在。

它并不存在,不是因为它在那里,而是计算机没有发现。它根本不存在。elasticsearch 7.6.2没有这样的方法;它从elasticsearch 7开始就被删除了。

作为一种解决方案,我将elasticsearch降级为6.8.13,现在一切都很好。只需将此添加到pom.xml/<properties>

代码语言:javascript
复制
<elasticsearch.version>6.8.13</elasticsearch.version>

如果有更好/更恰当的解决方案,请告诉我。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64608349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档