title: Embedded Kafka Broker IP Not Resolving in Property File
body: <p>I'm facing an issue where my Kafka <code>ProducerConfig</code> is getting an invalid <code>bootstrap.servers</code> value because my unit test <code>@PropertySource</code> isn't resolving the <code>spring.embedded.kafka.brokers</code> property. When I dump my producer config to the logs, I get the following:</p>
  
  <pre><code>acks = 0
  batch.size = 10000
  bootstrap.servers = [${spring.embedded.kafka.brokers}]
  ...
  </code></pre>
  
  <p>Clearly, the property isn't getting resolved. Suppose I have the following embedded Kafka test.</p>
  
  <pre><code>@EmbeddedKafka
  @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
  @RunWith(SpringRunner.class)
  public class EmbeddedKafkaTest {
  
      @Value("${spring.embedded.kafka.brokers}")
      private String embeddedKafkaBrokers;
  
      @Test
      public void test(){}
  
      @SpringBootConfiguration
      @PropertySource("classpath:kafkaTestProps.properties")
      @EnableAutoConfiguration
      class EmbeddedKafkaTestConfiguration {
      }
  
  }
  </code></pre>
  
  <p>and my <code>kafkaTestProperties.properties</code> file is as follows:</p>
  
  <pre><code>embedded-kafka-brokers=${spring.embedded.kafka.brokers}
  ...
  </code></pre>
  
  <p><code>embedded-kafka-brokers</code> will eventually be provided to Kafka's <code>ProducerConfig</code> through some underlying autoconfiguration.</p>
  
  <p>Interestingly, the <code>embeddedKafkaBrokers</code> instance field in the test class does contain the broker IPs set by embedded kafka.</p>
  
  <p>I've concluded there's an issue with the property source loading order, where <code>@EmbeddedKafka</code> isn't setting the broker IP system property in time for <code>kafkaTestProperties.properties</code> to resolve it. This problem arose after porting our code base to Spring Boot 2 and Spring Cloud Finchley SR2, where Spring Kafka APIs have upgraded.</p>
  
  <p>I've tried removing <code>@SpringBootTest</code> and wrapping the <code>test()</code> code in a <code>SpringApplicationBuilder</code> to no avail.</p>
  
  <p>Any advice as to how I can fix this? Perhaps I can leverage <code>@AutoConfigurationAfter</code> or <code>@Order</code>? Is there a way to order the loading of property sources?</p>