1 引言
使用 MyBatis-Spring 模块,我们可以在Spring中使用mybatis,让Spring容器来管理sqlSessionFactory单例的创建。如以下代码
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--指定数据源,不用再在mybatis的XML配置文件中指定environment了-->
<property name="dataSource" ref="dataSource" />
<!--指定configuration对象,它是创建sqlSessionFactory的核心,包含mybatis几乎全部的配置信息-->