mybatis默认一级缓存
当有多个mapper对象以同样查询条件的查询时 只执行一次sql
二级缓存
开启:
- 在mybatis.xm;配置文件中配置
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
默认为true
2.在mapper.xml中加入<cache />
针对mapper级别缓存的实现
3.结果及对象实现Serializable接口
public class UserInfo implements Serializable {
private String id;
private String userName;
private String password;
private List<Address> addresses;