title: config JUnit tests in Spring Boot with @EnableAutoConfiguration
body: <p>my server is like this</p>
  
  <pre class="lang-java prettyprint-override"><code>@ComponentScan
  @EnableAutoConfiguration
  public class Server {
      public static void main(String[] args) {
          SpringApplication server = new SpringApplication(Server.class);
          server.setShowBanner(false);
          server.run(args);
      }
  }
  </code></pre>
  
  <p>and my test config is like this</p>
  
  <pre class="lang-java prettyprint-override"><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = Server.class)
  public class MyTest {
      @Autowired
      JdbcTemplate jdbcTemplate;
      @Test
      public void test1(){
          int countRow = jdbcTemplate.queryForObject("select count(*) from basic_auto_brand;",Integer.class);
      }
  </code></pre>
  
  <p>and I will get the error:</p>
  
  <pre><code>10:35:28.719 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@6fd02e5] to prepare test instance [com.nwche.test.MyTest@5700d6b1]
  java.lang.IllegalArgumentException: Can not build an ApplicationContext with a NULL 'contextLoader'. Consider annotating your test class with @ContextConfiguration.
  </code></pre>