• springboot集成elasticsearch问题


    报错信息如下:

      Error creating bean with name 'elasticsearchTemplate' defined in class path

    解决思路:

    1.es版本与pom文件版本不符

      修改pom文件mvn版本

    2.jar包冲突

      将冲突的jar包exclusion

            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>6.2.4</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
                <version>6.2.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.elasticsearch</groupId>
                        <artifactId>elasticsearch</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>    

    3.启动类中设置

        public static void main(String[] args) {
            SpringApplication.run(EsDemoApplication.class, args);
            System.setProperty("es.set.netty.runtime.available.processors", "false");
        }    

    4.es版本与idea不兼容

      注释以下pom

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>

      手动添加pom依赖

         <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>6.2.4</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.elasticsearch.client/transport -->
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
                <version>6.2.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.elasticsearch</groupId>
                        <artifactId>elasticsearch</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>elasticsearch-rest-high-level-client</artifactId>
                <version>6.2.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.elasticsearch</groupId>
                        <artifactId>elasticsearch</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
  • 相关阅读:
    linux正则表达式
    linux监控值free命令详解
    loadrunner 中数组的定义
    管线工具sed和正则表达式
    web_link()参数化
    mysql执行插入时性能优化
    linux关闭防火墙
    linux系统中变量和环境变量
    mysql源码安装与基本优化配置
    Memory Consistency Erros
  • 原文地址:https://www.cnblogs.com/gaohuajie/p/12966328.html
Copyright © 2020-2023  润新知