相关文章推荐
狂野的荒野  ·  Caused by: ...·  1 月前    · 
傻傻的滑板  ·  ffmpeg处理视频与声音_ffmpeg ...·  8 月前    · 
八块腹肌的遥控器  ·  从JSON对象中提取键值对数据,使用Python。·  1 年前    · 
寂寞的眼镜  ·  如何设置ECS实例的报警规则?_云服务器 ...·  1 年前    · 
拉风的电池  ·  删除python中tar中的文件而不重写-腾 ...·  1 年前    · 
低调的羊肉串  ·  opencv 绿 幕抠图-掘金·  1 年前    · 
Code  ›  Spring Boot导致ElasticSearch版本冲突开发者社区
elasticsearch
https://cloud.tencent.com/developer/article/1418127
可爱的酱肘子
1 年前
作者头像
十毛
0 篇文章

Spring Boot导致ElasticSearch版本冲突

前往专栏
腾讯云
备案 控制台
开发者社区
学习
实践
活动
专区
工具
TVP
文章/答案/技术大牛
写文章
社区首页 > 专栏 > 用户1337634的专栏 > 正文

Spring Boot导致ElasticSearch版本冲突

发布 于 2019-04-25 11:37:09
3.3K 0
举报

使用Spring Boot新版后,ElasticSearch出现如下错误

Cannot register setting [http.netty.max_composite_buffer_components] twice

Caused by: java.lang.IllegalArgumentException: Cannot register setting [http.netty.max_composite_buffer_components] twice
    at org.elasticsearch.common.settings.SettingsModule.registerSetting(SettingsModule.java:172) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:74) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:141) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:268) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:133) ~[transport-5.6.16.jar:5.6.16]
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:119) ~[transport-5.6.16.jar:5.6.16]
    at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:109) ~[transport-5.6.16.jar:5.6.16]

原因

因为transport使用的是 5.5.3 版本,对应的 transport-netty3-client 也是 5.5.3 ,但是 transport-netty4-client 却被Spring Boot设置为 6.4.3

版本冲突

解决办法

transport-netty4-client也设置为 5.5.3

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>5.5.3</version>
</dependency>
<dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>transport-netty4-client</artifactId>
    <version>5.5.3</version>
</dependency>
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>5.5.3</version>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>transport-netty4-client</artifactId>
        </exclusion>
    </exclusions>
</dependency>

版本不兼容原因分析

在两个版本中,Netty3Plugin和Netty4Plugin都会去设置属性 http.netty.max_composite_buffer_components ,但是区别在于5.5.3中,这个属性是共享的 Property.Shared ,但是在6.4.3中该属性不是共享(其实共享的本意我还没有弄得很清楚)

  • 5.5.3 {Property.NodeScope, Property.Shared}
SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS = Setting.intSetting("http.netty.max_composite_buffer_components", -1, new Property[]{Property.NodeScope, Property.Shared});
  • 6.4.3 Property.NodeScope
public static Setting<Integer> SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS =
 
推荐文章
狂野的荒野  ·  Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no furthe
1 月前
傻傻的滑板  ·  ffmpeg处理视频与声音_ffmpeg 检查视频是否有声音-CSDN博客
8 月前
八块腹肌的遥控器  ·  从JSON对象中提取键值对数据,使用Python。
1 年前
寂寞的眼镜  ·  如何设置ECS实例的报警规则?_云服务器 ECS(ECS)-阿里云帮助中心
1 年前
拉风的电池  ·  删除python中tar中的文件而不重写-腾讯云开发者社区-腾讯云
1 年前
低调的羊肉串  ·  opencv 绿 幕抠图-掘金
1 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号