mybatis的二级缓存

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"/>

posted @ 2019-12-05 15:37  joycezz  阅读(113)  评论(0)    收藏  举报