# mybatis-plus-plus
**Repository Path**: nullbull/mybatis-plus-plus
## Basic Information
- **Project Name**: mybatis-plus-plus
- **Description**: Mybatis-Plus-Plus--支持两表关联查询的Mybatis-Plus插件
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 3
- **Forks**: 3
- **Created**: 2020-09-30
- **Last Updated**: 2022-07-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
### mybatis-plus-plus(mpp)
对mybatis-plus进行增强,支持多表关联查询
使用示例 demo https://github.com/nullbull/mybatis-plus-plus-demo
### 接入步骤
1. 将代码down到本地,使用maven install
2. 在自己的项目中添加依赖
```xml
com.github.mybatisplus
plus
1.0-SNAPSHOT
```
3. 配置方式
- SpringBoot 配置
```java
@Configuration
public class MybatisPlusConfig {
@Bean
public Interceptor myInterceptor() {
return new MyInterceptor();
}
@Bean
public ISqlInjector multiQueryInjector() {
return new MultiQueryInjector();
}
}
```
- Spring 配置方式
1. 在Spring初始化中修改MybatisSqlSessionFactoryBean
2. 添加 mpp 自定义的 mybatis 拦截器
```java
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setPlugins(new Interceptor[]{ new MyInterceptor()});
```
3. 添加 mpp 自定义的 默认方法
```java
GlobalConfig globalConfig = GlobalConfigUtils.defaults();
globalConfig.setSqlInjector(new MultiQueryInjector());
sqlSessionFactoryBean.setGlobalConfig(globalConfig);
```
4. 将mybaits plus 的BaseMapper 替换成mpp自定义的 MultiQueryMapper
### 如何使用
示例一:
```java
Query end = new Query(TestVo.class)
.select(F.f(Meeting::getId), F.f(Room::getId), F.f(Meeting::getTopic))
.joinOn(F.f(Meeting::getHostId), F.f(Room::getId))
.in(F.f(Meeting::getId), 1, 2)
.eq(F.f(Meeting::getTopic), "测试")
.end();
List