Mybatis-Plus(简称MP)是一个 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发、提高效率而生。
它已经封装好了一些crud方法,对于非常常见的一些sql我们不用写xml了,直接调用这些方法就行,但它也是支持我们自己手动写xml。
帮我们摆脱了用mybatis需要写大量的xml文件的麻烦,非常安逸哦
用过就不想用其他了,太舒服了
好了,我们开始整合整合
新建一个SpringBoot的工程
这里是我整合完一个最终的结构,可以参考一下
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://.zkb.service.UserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * <p> * 前端控制器 * </p> * * @author zkb * @since 2020-11-23 */@RestController@RequestMapping("/user")public class UserController { @Autowired private UserService userService; @GetMapping("/getUser") public User getUser(){ return userService.getById(1231); } }写了一个get方法来测试自己是否与mybatis-plus整合成功,所以直接调用了mybatis-plus内置的方法
当然数据库我自己手动写了一个id为1231的数据
可以看到整合成功了,对吧,真的是超级简单
点击此处demo下载,需要自取
到此这篇关于SpringBoot整合MybatisPlus的文章就介绍到这了,更多相关SpringBoot整合MybatisPlus内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!