软件版本
elasticsearch 6.8.6
JDK 1.8
第一步 springboot 版本升级为2.2.0.RELEASE
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
第二步 修改配置文件
spring:
elasticsearch:
rest:
username: elastic
password: hRnXw1VuvkixVn77uVHg
uris: http://127.0.0.1:9200
第三步 修改代码
将ElasticsearchTemplate
修改为ElasticsearchRestTemplate
。
ElasticsearchRestTemplate
功能更加强大,可以定义更复杂的查询。
打赏