由于springboot 2.3.0以后版本不支持自动注入JestClient,如下图我们在配置文件中配置JestClient时会出现红线提示。我们采取手动配置的方式
采用手动注入的方式:
@Test
void contextLoads() {
JestClient jestClient = getJestCline();
//List 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();
}
当然也可以降低版本 在springboot 2.2.x版本,声明废弃但是还可以使用的