title: Adding configuration class to SpringBootTest breaks component scan
body: <p>I am trying to disable real Mongo connection and replace it with Fongo mock in tests.</p>
  
  <p>Here is my test class:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @SpringBootTest
      @RunWith(SpringRunner.class)
      public class ControllerTest {
  
          @Autowired
          private WebApplicationContext wac;
  
          @Autowired
          private ObjectMapper objectMapper;
  
          @MockBean
          private MyService service;
  
          private MockMvc mockMvc;
  
          @Before
          public void setup() {
              this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
          }
  
          @Test
          public void performTest() throws Exception {
              ... logic ...
          }
      }
  </code></pre>
  
  <p>It works fine unless I try to add my configuration file changing this line:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @SpringBootTest
  </code></pre>
  
  <p>to this: </p>
  
  <pre class="lang-java prettyprint-override"><code>    @SpringBootTest(classes = TestConfig.class)
  </code></pre>
  
  <p>config class itself:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Configuration
      @ComponentScan
      @EnableMongoRepositories
      public class TestConfig extends AbstractMongoConfiguration {
  
          @Override
          protected String getDatabaseName() {
              return "FongoDB";
          }
  
          @Override
          public Mongo mongo() {
              return new Fongo(getDatabaseName()).getMongo();
          }
      }
  </code></pre>
  
  <p>Then application fails to find beans and throws the next exception:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
      ... 28 more
  </code></pre>
  
  <p>How can I fix it and apply additional configuration properly?</p>