mybatis学习:十

在mybatis中使用注解
1.定义接口,在接口上加入注解

public interface IStudentDao {

    @Insert("insert into student values(default,#{name},#{phone})")
    public int addStudent(Student student);

    @Delete("delete from student where id = #{id}")
    public int deleteStudent(int id);

    @Select("select * from student limit #{start},#{size}")
    public List selectPage(Map map);

    @Update("update student set name=#{name}, phone=#{phone} where id=#{id}")
    public int updateStudent(Student student);
}

2.在配置文件中标签中加入,把接口注册

    <mappers>
        
        <mapper class="com.han.dao.IStudentDao"/>
    mappers> 

你可能感兴趣的:(mybatis,mybatis,java)