title: Spring Boot + Mybatis @MapperScan and SqlSessionFactory
body: <p>Im developing a new app using Spring Boot. I use Mybatis for persistance. Im using Java Config for everything I can.</p>
  
  <p>I'm getting this exception when the app starts regarding creating my Mybatis mapper interface</p>
  
  <pre><code>exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
  </code></pre>
  
  <p>My Sring Boot application class is set up like this</p>
  
  <pre><code>@SpringBootApplication
  @MapperScan("com.mydomain.admin.service.dao")
  public class AdminApplication {
  
  public static void main(String[] args) {
      SpringApplication.run(AdminApplication.class, args);
  }
  }
  </code></pre>
  
  <p>The Mybatis mapper interface class is set up like this</p>
  
  <pre><code>package com.mydomain.admin.service.dao;
  public interface AdminClientDAO {
  @Select("SELECT clientId, name, enabledFlag as enabled, dateAdded, dateUpdated as updateDate FROM client")
  public List&lt;Client&gt; findAll();
  </code></pre>
  
  <p>}</p>
  
  <p>my datasource is configured with spring boot. I've named the properties
  spring.datasource.* so spring boot with auto-configure the data source</p>
  
  <p>Now, Im wondering if Im assuming too much spring boot magic. I assumed that spring boot would configure the sqlSessionFactory because mybatis was in the classpath.. </p>
  
  <p>Many examples I see show configuring the sqlSessionFactory as a @Bean in the Java Config.. Is this the way it should be done is should spring boot be doing some magic and auto-config  it?</p>