美文网首页
记一次ElasticSearch集成踩的小坑

记一次ElasticSearch集成踩的小坑

作者: 牧小鱼 | 来源:发表于2017-10-17 10:34 被阅读0次

    背景:之前产品里面用到的ElasticSearch服务,是单独部署的服务。调用的时候是后端发送http请求es服务器,返回结果后再次查询数据库获取数据。为了减少不必要的http请求,故将es服务集成到后端服务中。在此记录一下

    说做就做

    ElasticSearch版本5.0.1
    直接把es服务作为后端服务的module引入,启动服务。报错

    Caused by: java.lang.NoSuchFieldError: FAIL_ON_SYMBOL_HASH_OVERFLOW
        at org.elasticsearch.common.xcontent.json.JsonXContent.<clinit>(JsonXContent.java:76)
        at org.elasticsearch.common.xcontent.XContentType$1.xContent(XContentType.java:58)
        at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:698)
        at org.elasticsearch.common.settings.Setting.lambda$listSetting$26(Setting.java:656)
        at org.elasticsearch.common.settings.Setting$$Lambda$38/1908571316.apply(Unknown Source)
        at org.elasticsearch.common.settings.Setting$2.getRaw(Setting.java:660)
        at org.elasticsearch.common.settings.Setting.get(Setting.java:300)
        at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:164)
        at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:81)
        at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:106)
        at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:228)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:69)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:65)
        
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:310)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
        ... 146 more
    

    看下报错位置代码

    jsonFactory.configure(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); 
    

    发现

    com.fasterxml.jackson.core.JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW
    

    要求的jar包是jackson-core-2.8.1.jar。网上随意查了一下,基本上定位到是jar包冲突导致。
    直接上maven helper,分析有多少jar包冲突

    image.png

    发现冲突的jar包


    image.png image.png

    分别引用高版本的jackson-core 并打成jar包,重新启动

    Artifact is deployed successfully
    

    下图为ElasticSearch版本5.0.1依赖的Jackson.core的版本


    image.png

    如果有做的不对的地方,随时欢迎指正!

    相关文章

      网友评论

          本文标题:记一次ElasticSearch集成踩的小坑

          本文链接:https://www.haomeiwen.com/subject/tavluxtx.html