mybatis 注解
作用:简化配置文件
1.mybatis的注解是为了简化mapper.xml的配置文件
注意: 如果涉及动态SQL依然使用mapper.xml
2.mapper.xml和注解可以共存
3.使用注解时mybatis.xml中的配置如下
3.1 < package name=" “/>
3.2 < mapper class=” "/>
如下 在mapper接口中使用注解实现增删改查
查询
@Select("select *from people")
List<People> selAll();
新增
@Insert("insert into people values(default,#{name})")
int insPeople(Peoplepeople);
修改
@Update("update people set name=#{name} where id=#{id}")
int updPeople(People people);
删除
@Delete("delete from people where id=#{0}")
int delByid(int id);