package com.qianwen.mdc.collect.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; @Configuration public class MybatisPlusConfig { //@Value("${dbType}") private String dbType; /** * 根据配置获取数据库类型枚举值 * @return */ private DbType getMybatisPlusDbType() { return DbType.getDbType(dbType); } @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); /* DbType dtype = this.getMybatisPlusDbType(); if(dtype != DbType.MYSQL && dtype != DbType.ORACLE) {//稍后开发oracle的mapper来支持 if(dtype != DbType.MYSQL && dtype != DbType.ORACLE) { throw new java.lang.IllegalStateException("不支持的dbType:"+dtype); } */ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } }