码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • springboot 整合 es 配合使用 IK 分词器


    原文链接:https://blog.csdn.net/magic_1024/article/details/103246719

    版本:springboot 2.2.2 + es 6.8.4

    如果你的 es 和 redis 版本冲突了,试试更高版本的 netty:

    	<!-- 解决 mq 和 es 的冲突 -->
    	   <dependency>
    	       <groupId>io.netty</groupId>
    	       <artifactId>netty-all</artifactId>
    	       <version>4.1.68.Final</version>
    	   </dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    1.添加spring-data-elasticsearch依赖

    	<!--elasticsearch-->
          <dependency>
              <groupId>org.springframework.data</groupId>
              <artifactId>spring-data-elasticsearch</artifactId>
              <version>3.2.1.RELEASE</version>
         </dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2.application.properties添加ElasticSearch连接信息

    #Elasticsearch配置
    elasticsearch.host=127.0.0.1
    elasticsearch.port=9200
    
    • 1
    • 2
    • 3

    3.创建Elasticsearch配置类

    package com.example.demo.config;
    
    import lombok.extern.slf4j.Slf4j;
    import org.elasticsearch.client.Client;
    import org.elasticsearch.common.settings.Settings;
    import org.elasticsearch.common.transport.TransportAddress;
    import org.elasticsearch.transport.client.PreBuiltTransportClient;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
    import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
    import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
    
    import java.net.InetAddress;
    
    @Slf4j
    @Configuration
    @EnableElasticsearchRepositories(basePackages = "com.example.demo.dao")
    public class ElasticsearchConfig {
       
    
        @Value("${elasticsearch.host}")
        private String esHost;
    
        @Value("${elasticsearch.port}")
        private int esPort;
    
        @Value(
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    结合重心反向变异的飞蛾扑火优化算法-附代码
    一位同学的Python大作业【分析当当网书籍价格、出版社、电子书版本占比数据】
    全力以赴,火山引擎边缘云代表团出战亚运会
    探索 Electron Egg:构建跨平台桌面应用的理想选择
    ubuntu18.04安装python3.10.13
    redis(2)-hiredis-centos-ubuntu 下安装和使用
    JavaScript计算两个时间相差多少个小时的封装函数
    SpringBoot SpringBoot 运维实用篇 3 多环境开发 3.5 多环境开发控制
    mysql中金额用什么类型
    私域电商模式全解析:掌握这些方法,让你的生意不再难做!
  • 原文地址:https://blog.csdn.net/blue_mxy/article/details/126416628
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号