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