---
# System prepended metadata

title: Mybatis流程解析
tags: [Mybatis-基礎]

---

# Mybatis流程解析
###### tags: `Mybatis-基礎`

![](https://i.imgur.com/nWnH9iO.png)

1.Resourece加載配置文件
```java=
 String resource = "mybatis-config.xml";
```

2.實例化SqlSessionFactoryBuilder
```java=
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
```

3.配置信息存放在Configuration
![](https://i.imgur.com/LTKaUx0.png)

4.實例化SqlSessionFactory
```java=
public static SqlSession getSqlSession(){
        return sqlSessionFactory.openSession();
    }
```

5.執行器Excutor
![](https://i.imgur.com/PUz45X3.png)
