Py学习  »  Elasticsearch

Elasticsearch、Kibana基础知识(三) -- 整合Spring Boot

wingwingwing • 3 年前 • 265 次点击  
阅读 3

Elasticsearch、Kibana基础知识(三) -- 整合Spring Boot

<dependency>
        <groupId>org.elasticsearch.client</groupId>
	<artifactId>elasticsearch-rest-high-level-client</artifactId>
	<version>{version}</version>
</dependency>
复制代码
  @Bean
  public RestHighLevelClient ESRestClient() {
    return new RestHighLevelClient(RestClient.builder(new HttpHost("127.0.0.1", 9200, "http")));
  }
复制代码
可能遇到的报错1:
Found interface org.elasticsearch.common.bytes.BytesReference, but class was expected

-- highlevelclient版本和es版本不一致导致,因为springboot默认会管理es的版本,很有可能和你引入的client版本不一致
在<properties>中覆盖版本即可
<elasticsearch.version>7.4.2</elasticsearch.version>
复制代码

image.png

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/108687
 
265 次点击