title: Exclude Spring Cloud Config Server from Spring boot unit test
body: <p>Given I have the following 3 Beans:</p>
  
  <pre><code>@Component
  public class ServiceConfig {
      // This value is only available from the Spring Cloud Config Server
      @Value("${example.property}")
      private String exampleProperty;
  
      public String getExampleProperty() {
          return exampleProperty;
      }
  }
  
  @Component
  public class S1 {
      int i = 1;
  }
  
  @Component
  public class S2 {
  
      @Autowired
      S1 s1;
  
  }
  </code></pre>
  
  <p>I want to be able to run the following test:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class S2Test {
  
      @Autowired
      S2 s;
  
      @Test
      public void t2() {
          System.out.println(s.s1.i);
      }
  
  }
  </code></pre>
  
  <p>The issue I have is that since I want to test the <code>S2</code> class in isolation and since it uses <code>@Autowired</code> I must have a Spring context in my test, however when the Spring context is started it tries to create all 3 beans which includes the bean with <code>@Value</code>. Since this value is only available from Spring Cloud Config Server the context will fail to be created giving the error: <code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'example.property' in string value "${example.property}"</code>.</p>
  
  <blockquote>
    <p>My Question is: How are properties read from Spring Cloud Config
    Server handled in the application when unit tests are run, observe in
    my test i dont even care about the config so I dont want to explicitly
    have to set a value in my test just for the context to be started?</p>
  </blockquote>