RestHighLevelClient Bean for Elasticsearch not found on classpath in Spring Boot 3

huangapple go评论75阅读模式
英文:

RestHighLevelClient Bean for elasticsearch not found on classpath in spring boot 3

问题

我正在尝试将我的现有Spring Boot 2.7.x项目升级到Spring Boot 3.x.x。
我已经解决了一切,除了在运行应用程序时出现的此错误。


应用程序启动失败


描述:

com.cox.config.ShedLockConfiguration中方法lockProvider的参数0需要一个类型为'org.elasticsearch.client.RestHighLevelClient'的bean,但找不到该类型的bean。

操作:

考虑在您的配置中定义一个类型为'org.elasticsearch.client.RestHighLevelClient'的bean。

进程以退出码0完成

使用的Spring Boot版本是3.0.0
我知道RestHighLevelClient已被弃用,但文档说它仍然在spring-data-elasticsearch中可用

尝试将所有依赖项升级以与Spring Boot 3兼容

更新:
还有另一个与弹性搜索一起使用的组件出现以下错误,我正在尝试将其升级到Spring Boot 3


应用程序启动失败


描述:

com.cox.service.esindex.EsIndexRefreshService中构造函数的参数2需要一个类型为'org.springframework.data.elasticsearch.core.ElasticsearchOperations'的bean,但找不到该类型的bean。

操作:

考虑在您的配置中定义一个类型为'org.springframework.data.elasticsearch.core.ElasticsearchOperations'的bean。

看起来Spring Boot不再为已弃用的方法/类创建bean。您能否帮助我将每个已弃用的方法/类映射到新的spring-data-elasticsearch?

英文:

I am trying to upgrade my existing spring boot 2.7.x project to spring boot 3.x.x.
I have sorted out everything except this error while running the application.


APPLICATION FAILED TO START


Description:

Parameter 0 of method lockProvider in com.cox.config.ShedLockConfiguration required a bean of type 'org.elasticsearch.client.RestHighLevelClient' that could not be found.

Action:

Consider defining a bean of type 'org.elasticsearch.client.RestHighLevelClient' in your configuration.

Process finished with exit code 0

Spring Boot Version used is 3.0.0
I am aware that RestHighLevelClient is deprecated, but documentation says it's still available in spring-data-elasticsearch

Tried upgrading all dependencies to be compatible with spring boot 3

Update:
Also getting below error for another component with elastic search which I am trying to upgrade to spring boot 3


APPLICATION FAILED TO START


Description:

Parameter 2 of constructor in com.cox.service.esindex.EsIndexRefreshService required a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.data.elasticsearch.core.ElasticsearchOperations' in your configuration.

It looks like spring boot is no longer creating beans for deprecated methods/classes. Can you please help me map each deprecated method/class with the new spring-data-elasticsearch

答案1

得分: 0

以下是您要翻译的内容:

"documentation"明确指出:

旧的废弃的 RestHighLevelClient 仍然可以使用,但您需要显式地将其添加到应用程序的依赖项中,因为Spring Data Elasticsearch不再自动拉入它:

编辑 2023年2月18日:

查看文档,它还记录了如何配置不同的客户端。您需要自己进行此配置,我认为Spring Boot不会自动配置这一部分,它们正在使用Spring Data Elasticsearch的当前内容。

英文:

The documentation explicitly states:

> The old deprecated RestHighLevelClient can still be used, but you will need to add the dependency explicitly to your application as Spring Data Elasticsearch does not pull it in automatically anymore:

Edit 18.02.2023:

Check the documentation it also documents how to configure the different clients. You will have to do this configuraiton by yourself, I don't think that Spring Boot will configure this automatically, they are using the current stuff from Spring Data Elasticsearch .

huangapple
  • 本文由 发表于 2023年2月16日 18:51:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471193.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定