说明: 由于elastic 更新较快,这里只介绍spring boot 集成的elastic7.17.4 ,如果想直接使用elastic8,推荐你再搜搜别的 本文章大概可以坚持到2024年(如果更新会往后推) 没有2.7版本可以试着升一下spring boot2升级至2.7.3环境配置 这里使用的是ElasticsearchRestTemplate RestHighLevelClient 已弃用 ElasticsearchRepository已弃用 1. 引入elastic <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> <version>2.7.3</version> </dependency> 2. Yml配置 注意了,当前版本就是这个,原来的版本要注意会存在多字段 spring: elasticsearch: uris: 192.168.2.91:9200 3.