У меня ошибка: TransportAddress является абстрактным;не может быть создан .addTransportAddress (новый TransportAddress (InetAddress.getByName ("localhost"), 9300));
Code
import com.google.api.client.util.Value;
import org.elasticsearch.client.Client;
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Configuration
public class Config{
@Value("${elasticsearch.host:localhost}")
public String host;
@Value("${elasticsearch.port:9300}")
public int port;
public String getHost() {
return host;
}
public int getPort() {
return port;
}
@Bean
public Client client(){
TransportClient client = null;
try{
client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
} catch (UnknownHostException e) {
e.printStackTrace();
}
return client;
}
}
Пожалуйста, дайте мне знать, как это исправить