title: Connecting to Elasticsearch 6.2.3 with Spring Boot
body: <p>Trying to figure out how to get a working config for spring boot to connect to Elasticsearch 6.2.3, here's my connection code:</p>
  
  <p><strong>pom.xml</strong>:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-elasticsearch&lt;/artifactId&gt;
          &lt;version&gt;2.0.1.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>And my connection code:</p>
  
  <pre><code>import org.elasticsearch.client.transport.TransportClient;
  import org.elasticsearch.common.settings.Settings;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
  import java.net.UnknownHostException;
  
  
  @Configuration
  public class ElasticsearchConfig {
  
  @Bean
  public ElasticsearchTemplate elasticsearchTemplate() throws 
  UnknownHostException {
  
      Settings settings = Settings.builder()
              .put("client.transport.sniff", true).build();
  
      // Can't resolve symbol "PreBuiltTransportClient" 
      TransportClient client = new PreBuiltTransportClient(settings);
  
      return new ElasticsearchTemplate(client);
  
  }
  </code></pre>
  
  <p>}</p>