mybatis注解开发
在mybatis中针对CRUD一共有四个注解: @Select(),@Delete(),@Insert(),@Update() 示例: 在mybatis-config.xml中 < mappers > < ! -- < package name = "net.togogo.dao" > < / package > -- > < mapper class = "net.togogo.dao.IUserDao" > < / mapper > < / mappers > /** * 查询所有操作 * @return */ @Select ( "select * from user" ) List < User > findAll ( ) ; /** * 根据Id查询 */ @Select ( "select * from user where id = #{id}" ) User findById ( Integer id ) ; 当User类中的属性名和数据库的字段名不一致时可以这样: 一对一 mybatis-config.xml中: < mapper class = "net.togogo.dao.IAccountDao" > < / mapper > IAccountDao.java中 package net . togogo . dao ; import net . togogo