title: Why are the @Configuration classes not being run in Spring Boot tests?
body: <p>I have a Spring Boot <code>@Configuration</code> class that's located at <code>com.app.config</code> and a controller located at <code>com.app.controller</code> and my test (in the tests directory) is at <code>com.app.controller</code>. When I run it, the configuration class is never used.</p>
  
  <pre><code>package com.app.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.validation.Validator;
  import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  
  
  @Configuration
  @EnableWebMvc
  @ComponentScan("com.app")
  public class ValidationConfig {
  
      @Bean
      public Validator validator() {
  
          //The breakpoint here is never called!
          return new LocalValidatorFactoryBean();
      }
  }
  </code></pre>
  
  <p>Test class:</p>
  
  <pre><code>import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.test.context.junit4.SpringRunner;
  import org.springframework.validation.Validator;
  
  @RunWith(SpringRunner.class)
  @ComponentScan({"com.app","com.app.config"})
  public class TestAumController {
  
      //...elided...
  
      @Autowired
      private Validator validator;
  
      @Test
      public void testController() throws Exception {
          //..edlided...
      }
  }
  </code></pre>