Mybatis Plus 之开启、关闭二级缓存

一、开启MybatisPlus的全局配置:

#二级缓存
mybatis-plus.global-config.configuration.map-underscore-to-camel-case= true
mybatis-plus.global-config.configuration.cache-enabled=true

二、在对应的xml文件中,添加配置:




<mapper namespace="com.mapper.TableMapper">
          
        
        
        <cache eviction="FIFO" flushInterval="60000" size="1024" readOnly="true" />
        
mapper>

三、如果有写接口无需二级缓存,可在对应的地方添加:useCache=“false”

<select id="getCount" resultType="int" useCache="false">
       select count(1) from table
select>
注意:添加二级缓存的xml,对应的entity需要实现Serializable接口

你可能感兴趣的:(JAVA,mybatis-plus,mybatis,java,mysql)