pringboot 2.0 集成 mybaits-plus

1 添加依赖

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.0.2</version>
        </dependency>

2 配置

mybatis-plus:
      mapper-locations: classpath:/mapper/*/*.xml
      typeAliasesPackage: con.xxx.*.domain.po
      global-config:
        refresh: true
        db-config:
            #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
          field-strategy: NOT_EMPTY
           #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
          id-type: AUTO
          db-type: MYSQL
          column-like: false
          #数据库大写下划线转换
          capital-mode: false
          #删除
          logic-delete-value: 1
          #不删除
          logic-not-delete-value: 0
      configuration:
        map-underscore-to-camel-case: true
        cache-enabled: true

3 添加配置文件

@Configuration
@MapperScan("com.xxx.xxx.*.dao")
public class MybatisPlusConfig {

    /*
     * 分页插件,自动识别数据库类型
     * 多租户,请参考官网【插件扩展】
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * 逻辑删
     * @return
     */
    @Bean
    public ISqlInjector sqlInjector() {
        return new LogicSqlInjector();
    }
    /**
     * SQL执行效率插件
     */
    @Bean
    @Profile({"dev","test"})// 设置 dev test 环境开启
    public PerformanceInterceptor performanceInterceptor() {
        return new PerformanceInterceptor();
    }

}

这样就集成好了 更多api 可以去官网 http://mp.baomidou.com/

转载 http://www.51csdn.cn/article/114.html 

猜你喜欢

转载自blog.csdn.net/qq_43599835/article/details/83758068