springboot elasticsearch docker
首先先用docker 搭建 eshttps://s1.运维网.com/images/blog/201901/22/ecf603c22f0028aff90a31df2095eb30.png
搜索 es+springboot 大都又是 在本地 搭建的es。。于是觉得自己边搜边写一篇博客 作为记录使用
docker:
首先安装
docker pull elasticsearch
docker run -d --name es -p 9200:9200 -e "discovery.type=single-node" id
打开 服务器ip:9200 可以正常打开
docker exec -it es /bin/bash
cd plugins/
plugin install mobz/elasticsearch-head
服务器ip:9200/_plugin/head/ 打开管理插件
但登陆elasticsearch-head点击连接9200 没反应
docker exec -it /bin/bash
cd config
vi elsaticsearch.yml
增加以下两行
http.cors.enabled: true
http.cors.allow-origin: "*"即可
点击连接 解决问题
整合springboot过程及其痛苦 搜了无数博客 都不行 就是愣连接不上9300端口 。。 于是乎 暂停dockr部署 转为命令启动方式以后有时间在去看看
命令:
wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.8.tar.gz
tar -zxvf elasticsearch-5.6.8.tar.gz
外网:
config目录下面elasticsearch.yml
修改为 network.host: 0.0.0.0
启动
bin/.elasticsearch
Spring Data 9300端口集成
Restful API 9200端口集成
springboot整合es
实体类
indexName为索引库
type为表
@Document(indexName = "blog", type = "article")
public class Article implements Serializable {dao层
@Component
页:
[1]