【问题标题】:org.elasticsearch.common.transport.InetSocketTransportAddress not found on Elasticsearch 6在 Elasticsearch 6 上找不到 org.elasticsearch.common.transport.InetSocketTransportAddress
【发布时间】:2018-12-01 19:44:52
【问题描述】:

我的代码在 elasticsearch 5 中运行良好,但是当我从 5 升级到 6 时。它正在显示

org.elasticsearch.common.transport.InetSocketTransportAddress not found

完整的堆栈跟踪:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project elastic-store: Compilation failure
[ERROR] /home/elastic/elastic-store/src/main/java/com/qw/psence/store/es/common/ESClient.java:[12,42] cannot find symbol
[ERROR] symbol:   class InetSocketTransportAddress
[ERROR] location: package org.elasticsearch.common.transport
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]

谁能帮我解决这个问题?

注意:Elaticsearch jar 很好。

【问题讨论】:

    标签: elasticsearch elasticsearch-5 elasticsearch-6


    【解决方案1】:

    Elastic search 6.0 已删除 InetSocketTransportAddress 类。我通过用 TransportAddress 类替换 InetSocketTransportAddress 类解决了这个问题。

    // on startup
    
    TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
            .addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));
    
    // on shutdown
    
    client.close();
    

    【讨论】:

      【解决方案2】:

      有很多解决方案可以解决这个问题,但我遇到了这个错误,因为我试图使用 SpringBoot 进行基本的弹性搜索配置:

      我忘记启动 elasticsearch...

      :facepalm:

      所以,只是:

      1. 在 Elasticsearch 安装目录中的 bin 文件夹中打开命令行*
      2. 输入elasticsearch
      3. 按 Enter 键

      为确保它正常工作,请在浏览器中打开 http://localhost:9200/。您应该会收到一个 JSON 响应,其中包含名称、cluster_name、elasticsearch 版本等。

      *(在 Windows 上)打开 ES_INSTALLATION_DIR\elasticsearch-x.x.x\bin 文件夹,按住 Shift 键,右键单击文件夹区域并从下拉菜单中选择 Open command window here

      【讨论】:

        【解决方案3】:

        在我的情况下,问题是由 spring-boot-dependencies 拉入我的项目的 elasticsearch 版本冲突。如果您的 pom 没有从 spring-boot-starter-parent 继承,而是使用 dependencyManagement 部分导入 spring-boot-dependencies,并且您需要在类路径上使用旧版本的 elasticsearch,那么这里是解决方案:InetSocketTransportAddress。始终运行mvn -Dverbose=true help:effective-pom 并检查有效的 pom 是否存在冲突。 -Dverbose=true 在这里很重要。它允许查看不需要的依赖项来自何处。

        【讨论】:

          猜你喜欢
          • 2016-10-06
          • 2016-04-25
          • 2023-02-20
          • 1970-01-01
          • 2014-12-10
          • 2022-01-14
          • 1970-01-01
          • 1970-01-01
          • 2015-03-23
          相关资源
          最近更新 更多