时间:2021-07-01 10:21:17 帮助过:21人阅读
2. 加载mybatis
本文以spring中加载mybatis为参考
<!-- 配置集成Mybatis --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:/config/SQLMapConfig.xml" /> <property name="mapperLocations" value="classpath*:com/chinaap/*/**/infra/mybatis/*Mapper.xml" /> </bean>
接口中有如下方法。
public interface SqlSessionFactory { SqlSession openSession(); SqlSession openSession(boolean autoCommit); SqlSession openSession(Connection connection); SqlSession openSession(TransactionIsolationLevel level); SqlSession openSession(ExecutorType execType); SqlSession openSession(ExecutorType execType, boolean autoCommit); SqlSession openSession(ExecutorType execType, TransactionIsolationLevel level); SqlSession openSession(ExecutorType execType, Connection connection); Configuration getConfiguration(); }
接口的实现类
由sqlSessionFactoryBean产生的是默认的SqlSessionFactory(DefaultSqlSessionFactory)
mybatis源码分析(1)-----sqlSessionFactory创建
标签:defaults 源码分析 images com span etc 创建 factory ssi