jeecgboot mybatisplus
时间: 2023-12-12 20:35:56 浏览: 34
JeecgBoot是一个基于SpringBoot和MyBatis-Plus的快速开发平台,它提供了许多常用的功能和组件,例如代码生成器、多租户、动态数据源等。其中,MyBatis-Plus是一个优秀的MyBatis增强工具,它提供了许多实用的功能,例如通用Mapper、分页插件、性能分析插件等,可以大大提高开发效率和代码质量。
在JeecgBoot中使用MyBatis-Plus非常简单,只需要引入相关依赖并配置即可。例如,在pom.xml文件中添加以下依赖:
```xml
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3.1</version>
</dependency>
```
然后,在application.yml文件中配置数据源和MyBatis-Plus相关属性,例如:
```yaml
spring:
datasource:
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
type-aliases-package: com.example.demo.entity
```
这样就可以在JeecgBoot中使用MyBatis-Plus进行开发了。例如,在代码中使用QueryWrapper进行查询:
```java
QueryWrapper<User> wrapper = new QueryWrapper<>();
wrapper.eq("name", "张三");
List<User> userList = userService.list(wrapper);
```