Springboot工程Mybatis二级缓存配置


1、在application.yml配置cache-enabled: true

    mybatis:
      config-location: classpath:/mybatis-config.xml, classpath:mybatis/mybatis-config.xml
      mapper-locations: classpath:mappers/*.xml,classpath:mybatis/mapper/*.xml
      configuration:
        cache-enabled: true

2、在xxxMapper.xml添加 

     a)<cache></cache>
        
        b) <select id="selectBygoodsCataCodeAndprovinceCode" resultMap="BaseResultMap" useCache="true" >

3)实体对象要implements Serializable,否则报错

public class CompleteTime implements Serializable

4、启动工程,如果出现

Cache Hit Ratio . #表示缓存开启了.....

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM