在尝试用spring引导将应用程序从2.1.8更新为2.3.4时,我设法解决了一些错误并成功地构建了该应用程序,但是在尝试运行主应用程序之后,下面的错误消息一直在扼杀我
***************************
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的结果给出了
[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-client和elasticsearch-rest-client-sniffer是两种不同的依赖关系,所以它们不是相互冲突的吗?
编辑:
在我添加了@gowridev的注释所建议的以下依赖项之后
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-elasticsearch</artifactId>
<version>6.0.0.Beta3</version>
</dependency>错误保持不变,但变化不大。
***************************
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发布于 2020-11-02 06:48:04
结果,我误解了错误信息。
Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version在搜索此消息时,其他人在不同地方重复使用依赖关系时大多会遇到问题。这让我觉得我的理由是一样的。不是这样的。
关键不是版本不是单一,而是它不是与兼容的。
简单地说,
org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClientFactory.createClient()此方法正在调用
org.elasticsearch.client.RestClientBuilder.setMaxRetryTimeoutMillis()但正如错误信息所指出的,它并不存在。
它并不存在,不是因为它在那里,而是计算机没有发现。它根本不存在。elasticsearch 7.6.2没有这样的方法;它从elasticsearch 7开始就被删除了。
作为一种解决方案,我将elasticsearch降级为6.8.13,现在一切都很好。只需将此添加到pom.xml/<properties>
<elasticsearch.version>6.8.13</elasticsearch.version>如果有更好/更恰当的解决方案,请告诉我。
https://stackoverflow.com/questions/64608349
复制相似问题