导入依赖
配置jdk
Java编译版本
JavaScript规范
依赖版本问题
==问题:默认的版本和我们使用的ES版本不一致==
==解决:版本自定义==
注入RestHighLevelClient
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//spring两个步骤:
//1、找对象
//2、放到spring中待用
//3、如果是SpringBoot 就分析源码
// xxxAutoConfiguration xxxProperties
@Configuration //xml
public class ElasticSearchClientConfig {
@Bean //xml-bean
public RestHighLevelClient restHighLevelClient() {
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(new HttpHost("", 9200, "http")));
return client;
}
}
springboot源码中提供对象
本文由 guoxiaorui 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Aug 28, 2020 at 11:49 pm