springboot 整合mybatisPlus
0.简介
搭配mybatisX使用,可以自动生成mapper.xml文件里面的sql语句
需要手动创建一个mapper文件夹然后在里面创建一个mapper.xml文件
@TableName(“表名”) 表名和bean不一样的时候用这个
@MapperScan(basePackages = {“org.example.mapper”})
//指定扫描的mapper接口所在的包 用在@SpringBootApplication上 解决用太多的@Mapper的问题
1.引入依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3</version>
</dependency>
2.配置文件
server:
port: 9090
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/springboot_mybatisplus?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username

本文详细介绍了如何在SpringBoot项目中整合MybatisPlus,从简介、引入依赖、配置文件到Mapper、Service层和Controller层的优化,以及Bean的配置和启动步骤,帮助开发者高效地实现CRUD操作。
最低0.47元/天 解锁文章
831

被折叠的 条评论
为什么被折叠?



