Llastic与Elasticsearch和项目依赖项之间的版本冲突

时间:2017-10-27 18:44:31

标签: java elasticsearch lucene

我正在开发的项目需要使用Elasticsearch和依赖(我没有设计或指示其设计)利用Lucene并遇到两者之间的版本冲突。当我尝试启动项目时,出现以下错误

Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_5_2_1
    at org.elasticsearch.Version.<clinit>(Version.java:39)
    at org.elasticsearch.common.io.stream.StreamOutput.<init>(StreamOutput.java:74)
    at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:60)
    at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:57)
    at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:47)
    at org.elasticsearch.common.xcontent.XContentBuilder.builder(XContentBuilder.java:69)
    at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:726)
    at org.elasticsearch.common.settings.Setting.lambda$listSetting$26(Setting.java:672)
    at org.elasticsearch.common.settings.Setting$2.getRaw(Setting.java:676)
    at org.elasticsearch.common.settings.Setting.lambda$listSetting$24(Setting.java:660)
    at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:665)
    at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:660)
    at org.elasticsearch.common.network.NetworkService.<clinit>(NetworkService.java:50)
    at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:91)
    at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:119)
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:247)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:92)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:81)
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:71)

是否可以在不能指定依赖项设计或Elasticsearch的情况下解决它?

1 个答案:

答案 0 :(得分:0)

结束将错误中提到的Lucene核心依赖项版本添加到项目中。 build.gradle现在包含compile group: 'org.apache.lucene', name: 'lucene-core', version: '5.2.1',解决了这个问题。