|
|
@@ -5,6 +5,7 @@ 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.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.core.convert.support.DefaultConversionService;
|
|
|
@@ -26,12 +27,19 @@ import java.net.UnknownHostException;
|
|
|
**/
|
|
|
@Configuration
|
|
|
public class TransportClientConfig extends ElasticsearchConfigurationSupport {
|
|
|
+ @Value("${bok.es.cluster.name}")
|
|
|
+ protected String name;
|
|
|
+ @Value("${bok.es.port}")
|
|
|
+ protected String port;
|
|
|
+ @Value("${bok.es.address}")
|
|
|
+ protected String address;
|
|
|
@Bean
|
|
|
public Client elasticsearchClient() throws UnknownHostException {
|
|
|
- Settings settings = Settings.builder().put("cluster.name", "se4-es").build();
|
|
|
+ System.out.println(name+" "+address+" "+port);
|
|
|
+ Settings settings = Settings.builder().put("cluster.name", name).build();
|
|
|
TransportClient client = new PreBuiltTransportClient(settings);
|
|
|
//client.addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.68.76"), 9300));
|
|
|
- client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 19300));
|
|
|
+ client.addTransportAddress(new TransportAddress(InetAddress.getByName(address), Integer.valueOf(port)));
|
|
|
return client;
|
|
|
}
|
|
|
|