title: Spring Boot 2.0.0.M2 and Spring Data Elasticsearch configuration
body: <p>I'm trying to move my project to <code>Spring Boot 2.0.0.M2</code>.</p>
  
  <p>This is my old Spring Data Elasticsearch configuration:</p>
  
  <pre><code>import org.elasticsearch.client.Client;
  import org.elasticsearch.client.transport.TransportClient;
  import org.elasticsearch.common.transport.InetSocketTransportAddress;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Profile;
  import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
  import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
  import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
  
  @Profile("production")
  @Configuration
  @EnableElasticsearchRepositories(basePackages = "com.example.domain.repository.elasticsearch")
  public class ElasticsearchConfig {
  
      @Value("${elasticsearch.host}")
      private String host;
  
      @Value("${elasticsearch.port}")
      private int port;
  
      @Bean
      public Client client() throws Exception {
          return TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
      }
  
      @Bean
      public ElasticsearchOperations elasticsearchTemplate() throws Exception {
          return new ElasticsearchTemplate(client());
      }
  
  }
  </code></pre>
  
  <p>Right now I faced a following issue:</p>
  
  <pre><code>1. The method builder() is undefined for the type TransportClient
  2. InetSocketTransportAddress cannot be resolved to a type
  </code></pre>
  
  <p>On the Maven classpath I have <code>Spring Data Elasticsearch 3.0.0.M4</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/FJAs2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FJAs2.png" alt="enter image description here"></a></p>
  
  <p>How to properly configure current version of Spring Data Elasticsearch ?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>For my tests I use Embedded Elasticsearch with a following application.properties:</p>
  
  <pre><code>#Elasticsearch
  spring.data.elasticsearch.properties.http.enabled=true
  spring.data.elasticsearch.properties.http.port=9250
  spring.data.elasticsearch.properties.path.home=target/test-elasticsearch-db
  spring.data.elasticsearch.properties.transport.tcp.connect_timeout=60s
  </code></pre>
  
  <p>This is my ES test config:</p>
  
  <pre><code>@Profile("test")
  @Configuration
  @EnableElasticsearchRepositories(basePackages = "com.example.domain.repository.elasticsearch")
  public class ElasticsearchTestConfig {
  }
  </code></pre>
  
  <p>Right now the test fails with a following error:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticsearchTemplate' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.elasticsearch.client.Client' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:726) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:458) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.elasticsearch.client.Client' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1478) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1089) ~[spring-beans-5.0.0.RC2.jar:5.0.0.RC2]
  </code></pre>
  
  <p>What is wrong here and how to fix this ?</p>