mybatis的二级缓存:
1.实体类实现序列化接口.
implements Serializable
2.在mapper.xml中开启mybatis自带的二级缓存(需要用到那个实体的缓存就开启)
仅仅作用于该mapper中
<!--开启mtbatis自带的二级缓存-->
<cache type="org.apache.ibatis.cache.impl.PerpetualCache"/>
3.在sqlMapConfig.xml中开启mybatis的二级缓存
<!--开启mybatis的二级缓存-->
<setting name="cacheEnabled" value="true"/>
![mybatis的二级缓存机制](https://img-blog.csdnimg.cn/20191205160638167.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0pveWNlX3poZW5nX291,size_16,color_FFFFFF,t_70)