pom.xml导入坐标
<!--ES-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
注意是这个版本
spring.yml配置
spring: elasticsearch: rest: uris: http://127.0.0.1:9200
导入模板就可以用了
@Autowired
private ElasticsearchRestTemplate esTemplate;