gpt4 book ai didi

java - 试图调用一个不存在的方法...纠正类路径

转载 作者:行者123 更新时间:2023-12-03 02:11:19 28 4
gpt4 key购买 nike

尝试使用Spring Boot从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-clientelasticsearch-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

最佳答案

原来我误解了错误信息。

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>
如果有更好/更合适的解决方案,请告诉我。

关于java - 试图调用一个不存在的方法...纠正类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64608349/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com