SpringBoot整合Elasticsearch注解式开发
前言:以往操作Es要写非常多的代码,真的累了,现在终于有封装好的代码怎么能不用呢。
pom引入jar
<!-- https://mvnrepository.com/artifact/cn.zxporz/esclientrhl -->
<dependency>
<groupId>cn.zxporz</groupId>
<artifactId>esclientrhl</artifactId>
<version>7.0.2</version>
</dependency>
启动类
yml配置文件
elasticsearch:
host: 127.1.1.0:9200
username: elastic
password: xxx
#连接池里的最大连接数
max_connect_total: 30
#某一个/每服务每次能并行接收的请求数量
max_connect_per_route: 10
#http clilent中从connetcion pool中获得一个connection的超时时间
connection_request_timeout_millis: 2000
#响应超时时间,超过此时间不再读取响应
socket_timeout_millis: 30000
#链接建立的超时时间
connect_timeout_millis: 2000
实体类
业务类(ElasticsearchTemplate类可进行对Es数据操作)