ES报错The following candidates were found but could not be injected

遇到的问题

The following candidates were found but could not be injected:
- Bean method ‘elasticsearchTemplate’ in ‘ElasticsearchDataConfiguration.RestClientConfiguration’ not loaded because @ConditionalOnMissingBean (names: elasticsearchTemplate types: org.springframework.data.elasticsearch.core.ElasticsearchOperations; SearchStrategy: all) found beans of type ‘org.springframework.data.elasticsearch.core.ElasticsearchOperations’ elasticsearchTemplate and found beans named elasticsearchTemplate

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2024-02-19 20:11:04.894 ERROR 31172 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Field elasticsearchRestTemplate in cn.yiyuan.gift.service.impl.GiftSearchServiceImpl required a bean of type ‘org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate’ that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

The following candidates were found but could not be injected:
- Bean method ‘elasticsearchTemplate’ in ‘ElasticsearchDataConfiguration.RestClientConfiguration’ not loaded because @ConditionalOnMissingBean (names: elasticsearchTemplate types: org.springframework.data.elasticsearch.core.ElasticsearchOperations; SearchStrategy: all) found beans of type ‘org.springframework.data.elasticsearch.core.ElasticsearchOperations’ elasticsearchTemplate and found beans named elasticsearchTemplate

Action:
Consider revisiting the entries above or defining a bean of type ‘org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate’ in your configuration.
Process finished with exit code 1
解决
注入的es不匹配
@Autowired
private ElasticsearchRestTemplate elasticsearchRestTemplate;
修改为正确的
@Autowired
private ElasticsearchTemplate elasticsearchRestTemplate;
问题完美解决,希望可以帮到你

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-23 16:44:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-23 16:44:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-23 16:44:02       82 阅读
  4. Python语言-面向对象

    2024-02-23 16:44:02       91 阅读

热门阅读

  1. 【机器学习】机器学习是什么?

    2024-02-23 16:44:02       51 阅读
  2. SQL中为什么不要使用1=1

    2024-02-23 16:44:02       53 阅读
  3. HW面试常见知识点(新手认识版)

    2024-02-23 16:44:02       49 阅读
  4. android recyclerview 中的animation滚动中动画停止了?

    2024-02-23 16:44:02       50 阅读
  5. Android自编译Pixel3内核加入KernelSU

    2024-02-23 16:44:02       53 阅读
  6. 配置docker 支持GPU方法(Nvidia GPU)

    2024-02-23 16:44:02       56 阅读
  7. Cookies

    2024-02-23 16:44:02       42 阅读
  8. kafka消费消息并对消息进行RSA公钥解密

    2024-02-23 16:44:02       46 阅读
  9. 【Ant Design】【List】

    2024-02-23 16:44:02       50 阅读
  10. 服务器防火墙的应用技术有哪些类型?

    2024-02-23 16:44:02       48 阅读