Spring Boot uses spring-boot-starter-data-elasticsearch to integrate and operate Elasticsearch

I have introduced several methods of operating ES before

  • Install Elasticsearch-Heador use Postman, or use the official Kibana to directly request the interface, and at the same time
  • Use officially recommendedJava High Level REST Client
  • Use the Spring Data Elasticsearch framework in the Sping Data project
  • Use Spring Boot to integrate Elasticsearch

The fourth way is also the content of this article

Spring Boot's integration of Elasticsearch is similar to Spring Data Elasticsearch, but the configuration and dependencies are different

One, Maven dependency

<!--https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
            <version>2.3.0.RELEASE</version>
        </dependency>

Second, placement application.properties

spring.elasticsearch.rest.uris=http://localhost:9200
# spring.elasticsearch.rest.username= // 用户名
# spring.elasticsearch.rest.password=// 密码
# spring.elasticsearch.rest.connection-timeout= // 连接超时时间
# spring.elasticsearch.rest.read-timeout= // 读取超时时间

Three, CRUD operation

It is similar to CRUD of Spring Data Elasticsearch, so I won't repeat it here.

Reference: https://blog.csdn.net/y1534414425/article/details/108989217

Guess you like

Origin blog.csdn.net/y1534414425/article/details/109040825