title: @WebMvcTest mapperscan conflict
body: <p>My project used <code>spring-boot</code> (1.4.0.release) and <code>mybatis-spring-boot-starter</code>. When I try to have some test code for controller, I always get a exception </p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  at org.springframework.util.Assert.notNull(Assert.java:115)
  at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:75)
  at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:74)
  at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
  ... 42 more`
  </code></pre>
  
  <p>But when I comment <code>@MapperScan("com.toby.mapper")</code>, it runs very well.
  Here is my example class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@MapperScan("com.toby.mapper")
  @EnableTransactionManagement
  @EnableConfigurationProperties(AppConfig.class)
  @SpringBootApplication(scanBasePackages = "com.toby.configuration,com.toby.web.controller,com.toby.service,com.toby.dao")
  public class Example {
  
      public static void main(String[] args) throws Exception {
          //new SpringApplicationBuilder().sources(Example.class).run(args);
          SpringApplication application=new SpringApplication(Example.class);
          application.addInitializers(new PropertyPasswordDecodingContextInitializer());
          application.run(args);
      }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my test code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package com.toby.web.controller;
  
  import com.toby.common.config.AppConfig;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
  import org.springframework.boot.test.mock.mockito.MockBean;
  import org.springframework.test.context.junit4.SpringRunner;
  import org.springframework.test.web.servlet.MockMvc;
  
  /**
   * Created by Toby on 2016/8/10.
   */
  @RunWith(SpringRunner.class)
  @WebMvcTest(value = MyRestController.class)
  public class MyRestControllerTests {
      @Autowired
      private MockMvc mvc;
  
      @MockBean
      private AppConfig appConfig;
  
      @Test
      public void testHome() throws Exception {
          /*this.mvc.perform(get("/users").accept(MediaType.TEXT_PLAIN))
                  .andExpect(status().isOk()).andExpect(content().string("Honda Civic"));*/
      }
  }</code></pre>
  </div>
  </div>
  </p>