SpringBoot整合Mybatis
依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> 纯注解版 如何告诉Spring容器,哪个接口是Mapper呢? 一般我们的都是单独创建一个mapper的packet, 闲麻烦可以选择使用 @Mapper 注解标记在单个mapper接口上,或者使用 @MapperScan 完成mapper的批量扫描 完成简单注解版的CURD 方法的名字见名知意就行,但是方法的返回值得是注解上sql对应的返回值 查询 @Select @Select("select * from person where id=#{id}") public Person getPersonById(Integer id); 删除 @Delete @Delete("delete from person where id = #{id}") public int deletePersonById(Integer id); 添加 @Insert // 添加Options注解,指定主键自增长, keyProperty 指定主键是谁,效果是运行完insert语句后