title: Spring and Mybatis multiple data sources setup
body: <p>My applications uses Spring3+MyBatis3. I'm trying to setup multiple data source for it. Setup looks like:</p>
  
  <pre><code>&lt;!-- db1 setup--&gt;
  &lt;bean id="db1SqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
      p:configLocation="WEB-INF/mybatis/sqlMapConfig.xml"
      p:dataSource-ref="db1DataSource" /&gt;
  &lt;bean id="db1SqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"&gt;
      &lt;constructor-arg ref="db1SqlSessionFactory"/&gt;
  &lt;/bean&gt;
  &lt;!-- db2 setup --&gt;
  &lt;bean id="db2SqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
      p:configLocation="WEB-INF/mybatis/sqlMapConfig.xml"
      p:dataSource-ref="db2DataSource" /&gt;
  &lt;bean id="db2SqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"&gt;
      &lt;constructor-arg ref="db2SqlSessionFactory"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In the logs, I've found this message:</p>
  
  <pre><code>No unique bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 2: [db1SqlSessionFactory, db2SqlSessionFactory]
  </code></pre>
  
  <p>I googled and looked into mybatis manuals but couldn't find way how to setup multiple data sources with mybatis. 
  Any ideas?</p>