1、手动清空
sqlSession.clearCache()
2、Options注解
public interface UserMapper{
@Options(flushCache= Options.FlushCachePolicy.TRUE)
User selectById(@params("id")Integer id)
}
3、调用了修改的方法时,底层直接调用sqlSession.clearCache()一次性全部清空
4、在setting中关闭一级缓存
locaCacheScope = STATEMENT
5、手动提交/回滚