tkmybatis开启二级缓存

1.MyBatis配置文件开启二级缓存功能 

<settings> 
<settingname="cacheEnabled"value="true"/> 
</settings>

2.在 XxxMapper 接口上使用@CacheNamespace 注解 

@CacheNamespace
 public interface EmployeeMapper extends MyMapper<Employee>{

}

3.实体类上实现序列化

public class Employee implements Serializable {
	
	private static final long serialVersionUID = 1L;

项目搭建

 pom依赖:

<dependency><groupId>tk.mybatis</groupId>
    <artifactId>mapper</artifactId>
    <version>4.0.0-beta3</version>
</dependency>

 配置文件更改:

猜你喜欢

转载自blog.csdn.net/qq_15204179/article/details/84889749
今日推荐