试图调用不存在的方法...更正类路径
An attempt was made to call a method that does not exist ... Correct the classpath
在尝试使用 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
我做了很多研究,包括 和很多与我相似的案例,但我发现它们最终是不同的。例如,在我的案例中,似乎只有一个位置提供 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
原来是我误会了错误信息
Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version
其他人在搜索此消息时,大多遇到依赖项在不同地方重复的问题。这让我觉得我的也是同样的原因。那不是。
关键不是版本不是single,而是版本不是兼容.
简单地说,
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>
如果有 better/more 正确的解决方案,请告诉我。
在尝试使用 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
我做了很多研究,包括 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
原来是我误会了错误信息
Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.search.engine.Version
其他人在搜索此消息时,大多遇到依赖项在不同地方重复的问题。这让我觉得我的也是同样的原因。那不是。
关键不是版本不是single,而是版本不是兼容.
简单地说,
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>
如果有 better/more 正确的解决方案,请告诉我。