ElasticSearch java 使用报错
Exception in thread "main" java.lang.NoSuchFieldError: FAIL_ON_SYMBOL_HASH_OVERFLOW
at org.elasticsearch.common.xcontent.json.JsonXContent.<clinit>(JsonXContent.java:77)
at org.elasticsearch.common.xcontent.XContentType$1.xContent(XContentType.java:60)
at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:868)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$29(Setting.java:814)
at org.elasticsearch.common.settings.Setting$$Lambda$29/1945604815.apply(Unknown Source)
at org.elasticsearch.common.settings.Setting$2.getRaw(Setting.java:818)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$27(Setting.java:802)
at org.elasticsearch.common.settings.Setting$$Lambda$30/940060004.apply(Unknown Source)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:807)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:802)
at org.elasticsearch.common.network.NetworkService.<clinit>(NetworkService.java:50)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:98)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:265)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:130)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:116)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:106)
at com.lhcis.bond.business.constant.ESTest.getTransPortClient(ESTest.java:41)
at com.lhcis.bond.business.constant.ESTest.testSearch(ESTest.java:61)
at com.lhcis.bond.business.constant.ESTest.main(ESTest.java:85)
我的项目是maven引入依赖
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.5.1</version>
</dependency>
此问题已解决,就是
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
jackson版本不对,因为elasticsearch里也引入jackson,两个版本不对就会报这个错误,改过来一样的版本,或者去除elasticsearch版本依赖,可以直接用你的pom里的版本就可以了。
本文转自 豆芽菜橙 51CTO博客,原文链接:http://blog.51cto.com/shangdc/2051244