mybatis的增删查改之通用Mapper

来源:互联网 发布:php正则表达式手册 编辑:程序博客网 时间:2024/05/22 02:16

通用Mapper使用流程

一,在sqlmapconfig.xml里面配置拦截器(注意顺序)

<!-- 使用通用Mapper,配置拦截器 -->
<plugin interceptor="com.github.abel533.mapperhelper.MapperInterceptor">
<!--主键自增回写方法,默认值MYSQL,详细说明请看文档 -->
<property name="IDENTITY" value="MYSQL" />
<!--通用Mapper接口,多个通用接口用逗号隔开 -->
<property name="mappers" value="com.github.abel533.mapper.Mapper" />
</plugin>

二,新建一个接口,继承公共的pojo:

public interface UserInfoMapper extends Mapper<User>{
三,3,在公共的pojo里面加注解:

@Table(name="user")
public class User {
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// 用户名
private String userName;
// 密码
private String password;

get/set





原创粉丝点击