欢迎投稿

今日深度:

Spring Boot集成ElasticSearch,

Spring Boot集成ElasticSearch,


下载ElasticSearch

下载地址    https://www.elastic.co/downloads/past-releases

Spring Boot集成ElasticSearch(gradle)

// 添加  Spring Data Elasticsearch 的依赖
compile('org.springframework.boot:spring-boot-starter-data-elasticsearch')

// 添加  JNA 的依赖
compile('net.java.dev.jna:jna:4.3.0')

版本问题解决

application.properties

# Elasticsearch服务地址
spring.data.elasticsearch.cluster-nodes=localhost:9300
# 设置连接超时时间
spring.data.elasticsearch.properties.transport.tcp.connect_timeout=120s

定义索引实体类

org.springframework.data.elasticsearch.annotations.Document

类名上加@Document(indexName = "索引库名称" , type = "索引库类型")注解

org.springframework.data.annotation.Id

定义一个主键字段加@Id注解  索引ID , 类型为String

查询方法使用

自定义接口继承ElasticsearchRepository<索引实体类,String>

ElasticSearch具体用法

这个大神写的很详细了

https://www.cnblogs.com/guozp/archive/2018/04/02/8686904.html

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/29457.html NewsArticle Spring Boot集成ElasticSearch, 下载ElasticSearch 下载地址    https://www.elastic.co/downloads/past-releases Spring Boot集成ElasticSearch(gradle) // 添加 Spring Data Elasticsearch 的依赖compile('org.springframework.boot:s...
相关文章
    暂无相关文章
评论暂时关闭