当前位置: 首页 > 图灵资讯 > 技术篇> Mybatis中二级缓冲的设置步骤

Mybatis中二级缓冲的设置步骤

来源:图灵教育
时间:2023-05-10 17:21:54

Mybatis中二级缓冲设置步骤

在mybatiss中打开全局配置文件.在xml文件中设置,默认为truee <settings> <setting name="cacheEnabled" value="false"/> </settings>

2.添加到mapper文件中:

<cache>或<cached-ref>

3.在select语句中配置usecache=true,默认为true

<select id="selectPage" resultMap="usersMap" useCache="true">

4.实体类需要实现Serializable的序列接口

public class User implements Serializable { private int id; private String userName; private String password;}