title: Spring Boot Elasticsearch Configuration
body: <p>I've got a working Spring Boot Elasticsearch Application which uses one of two profiles:  application.dev.properties or application.prod.properties.  That part works fine.  I am having issue with getting the external elasticsearch to read from the application.xxx.properties.</p>
  
  <p>This works:</p>
  
  <pre><code>@Configuration
  @PropertySource(value = "classpath:config/elasticsearch.properties")
  public class ElasticsearchConfiguration {
  
      @Resource
      private Environment environment;
  
      @Bean
      public Client client() {
          TransportClient client = new TransportClient();
          TransportAddress address = new InetSocketTransportAddress(
                  environment.getProperty("elasticsearch.host"), 
                  Integer.parseInt(environment.getProperty("elasticsearch.port"))
          );
          client.addTransportAddress(address);        
          return client;
      }
  
      @Bean
      public ElasticsearchOperations elasticsearchTemplate() {
          return new ElasticsearchTemplate(client());
      }
  }
  </code></pre>
  
  <p>but obviously doesn't solve my multi-environment issue.</p>
  
  <p>I've also tried @Value annotations for host and port variables without success.</p>
  
  <p>How can I convert the above to read its values from the application properties file or choose a different @PropertySource file based on whichever profile I want to run?</p>
  
  <pre><code>spring.data.elasticsearch.properties.host = 10.10.1.10
  spring.data.elasticsearch.properties.port = 9300
  </code></pre>
  
  <p>Thanks</p>