我正在使用Elasticsearch版本6.2.4。 启用xpack安全性后,我无法将传输客户端连接到elasticsearch
TransportClient transportClient1 = new PreBuiltXPackTransportClient(
Settings.builder().put("cluster.name", "Elastic-application")
.put("xpack.security.user", "elastic:pass@123")
.build());
ipPortMapping = ExportMiscellaneousUtils.getURLDetails(connectionURL, ExportMiscellaneousUtils.DEFAULT_TCP_PORT_ELASTICSEARCH);
for (Map.Entry<InetAddress, Integer> ipPortDetails : ipPortMapping.entrySet()) {
transportClient1.addTransportAddresses(new TransportAddress(ipPortDetails.getKey(), ipPortDetails.getValue()));
}
以下是我添加到我的Maven中的依赖项
<elasticsearch.version>6.2.4</elasticsearch.version>
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>6.0.0-beta2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
有什么想法吗?