一级缓存(不需配置,默认为一级缓存):
1)相当于 sqlsession 级别的缓存
2)当 session 关闭(close)或者提交(commit)后,缓存数据清空
3)当发生insert、update、delet等缓存数据会立即失效
二级缓存(手动配置):
1)相当于 sqlsessionFactory 级别的缓存
2)<setting name="cacheEnabled" value="true"/> (myBatis-config.xml 配置文件)
3)第三方工具的配置 (mapper.xml 配置文件)
一、myeclipse自带:<cache/>>
二、其 他 工 具 :<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
4)public class User implement serializable (pojo.User 实体类必须实现 serializable)