首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >springboot 2.3.0以后版本使用JestClient操作elasticsearch

springboot 2.3.0以后版本使用JestClient操作elasticsearch

作者头像
CodeWwang
发布2022-08-24 10:46:26
发布2022-08-24 10:46:26
6600
举报
文章被收录于专栏:CodeWwangCodeWwang

Springboot 2.3.0以后版本不支持自动注入JestClient,如下图我们在yml文件中配置JestClient时会出现划掉的线提示。我们采取手动配置的方式。如果只修改springboot版本,不手动添加bean注入会出现以下报错:

代码语言:javascript
复制
java Parameter 0 of constructor in xx.xx.xx.SearchServiceImpl required a bean of type 'io.searchbox.client.JestClient' that could not be found. 

采用手动注入的方式:

代码语言:javascript
复制
 @Test 
 void contextLoads() { 
 JestClient jestClient = getJestCline(); 
 //List<PmsSkuInfo> pmsSkuInfos= skuService.findAllSkuInfo(); 
 System.out.println("jestClient"+jestClient); 
 } 
 public JestClient getJestCline(){ 
 JestClientFactory factory = new JestClientFactory(); 
            factory.setHttpClientConfig(new HttpClientConfig 
 .Builder("http://10.12.11.100:9200") 
 .multiThreaded(true) 
 .build()); 
 return  factory.getObject(); 
 ` 

这样就不会报错了。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/12/30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档