将elasticsearch版本从2.3.3更新到5.6.3时出错

时间:2017-11-13 05:52:31

标签: java maven elasticsearch

我的项目使用的是spring-boot 1.3.5,我正在尝试将项目中的弹性搜索版本从2.3.3更新到5.6.3,我正在使用以下步骤创建客户端: -

 Client client = new PreBuiltTransportClient(Settings.EMPTY)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));

但是当我运行我的程序时,它会给我以下错误: -

java.lang.NoSuchMethodError: org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:97)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:58)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:433)
    at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:96)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:45)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:66)

但是,如果我将spring-boot版本从1.3.5升级到1.5.8,那么弹性搜索5.6.3正在运行。 我在pom.xml中使用了以下依赖项

<dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>5.6.3</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.7</version>
            </dependency>


            <dependency>
                <groupId>org.elasticsearch.plugin</groupId>
                <artifactId>delete-by-query</artifactId>
                <version>2.0.0-rc1</version>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
                <version>5.6.3</version>
            </dependency>

请求我告诉我如何使用spring-boot 1.3.5

解决该错误

0 个答案:

没有答案