标签:exception elastics catch dep utils port artifact 版本 enc
依赖
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.4.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.4.1</version>
</dependency>
版本自行选择 注意修改
工具类
package com.util;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import java.net.InetAddress;
public class ESUtils {
public static TransportClient getClient(){
try {
TransportClient transportClient = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
return transportClient;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
}
标签:exception elastics catch dep utils port artifact 版本 enc
原文地址:https://www.cnblogs.com/slAmor/p/11953465.html