SpringBoot集成ElasticSearch及ElasticsearchRepository

怎么搭建Elasticsearch服务就不多说了,可参考:

Elasticsearch5.2.1集群搭建 https://blog.youkuaiyun.com/Gamer_gyt/article/details/59077189

 

1.添加配置及依赖

spring: 
    data:
       elasticsearch: 
            cluster-name: es 
            cluster-nodes: 192.168.120.103:9300,192.168.120.104:9300
dependencies {
   compile 'org.springframework.boot:spring-boot-starter-data-elasticsearch:1.5.8.RELEASE'
}

2.实体类,定义索引、类型、字段

package com.demo.pojo;

import java.io.Serializable;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;


@Document(indexName = "apilog_index", type = "apilog")
public class ApiLog implements Serializable {
	private static final long serialVersionUID = -3823181217
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值