maven项目引入6.1.2的elasticsearch,但是找不到InetSocketTransportAddress,需要引用什么
Elasticsearch | 作者 PhoebM | 发布于2018年02月01日 | 阅读数:9125
pom文件中引入6.1.2版本的elasticsearch
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.1.2</version>
</dependency>
但是找不到InetSocketTransportAddress;; 报红线client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(cluster_serverip), 9300));
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.1.2</version>
</dependency>
但是找不到InetSocketTransportAddress;; 报红线client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(cluster_serverip), 9300));
2 个回复
shiyuan
赞同来自: PhoebM
thislj
赞同来自:
transport6.1.2依赖transport-netty4-client相应的版本,如果pom文件没有显示引入transport-netty4-client依赖并指定版本,maven会自动引入较低的版本,而在transport-netty4-client较低的版本中会使用InetSocketTransportAddress这一个类,transport6.1.2又没有这个类,就会报找不到类的异常。
解决:
在pom文件中加入下面这段
<!-- https://mvnrepository.com/arti ... lient -->
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>6.1.2</version>
</dependency>