一、自带二级缓存
步骤:
1.在总配置文件中配置启用二级缓存
2.在需要进行二级缓存的mapper.xml中配置
3.测试
1.mybatis.xml
2.mapper.xml
3.test.java
4.console
二、使用第三方缓存(ehcache)
步骤:
1.导入ehcache依赖
2.配置ehcache.xml
3.在总配置文件中配置启用二级缓存
4.在需要进行二级缓存的mapper.xml中配置
5.测试
1.pom.xml
2.ehcache.xml
3.mybatis.xml
4.mapper.xml
5.测试同上