Browse Source

处理依赖.

聂秋荣 7 years ago
parent
commit
a3ea4aae4a
29 changed files with 55 additions and 3489 deletions
  1. 23 2
      build.gradle
  2. 25 26
      mybatis-plus-core/build.gradle
  3. 0 465
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java
  4. 0 81
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/InjectionConfig.java
  5. 0 67
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/ConstVal.java
  6. 0 179
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/DataSourceConfig.java
  7. 0 57
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/FileOutConfig.java
  8. 0 206
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/GlobalConfig.java
  9. 0 146
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/PackageConfig.java
  10. 0 389
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java
  11. 0 94
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java
  12. 0 650
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java
  13. 0 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/builder/package-info.java
  14. 0 64
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/MySqlTypeConvert.java
  15. 0 59
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/OracleTypeConvert.java
  16. 0 64
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/PostgreSqlTypeConvert.java
  17. 0 58
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/SqlServerTypeConvert.java
  18. 0 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/package-info.java
  19. 0 160
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java
  20. 0 59
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableFill.java
  21. 0 254
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java
  22. 0 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/package-info.java
  23. 0 77
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/DbColumnType.java
  24. 0 38
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/DbType.java
  25. 0 132
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/NamingStrategy.java
  26. 0 135
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/QuerySQL.java
  27. 0 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/package-info.java
  28. 0 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/package-info.java
  29. 7 7
      mybatis-plus-generate/build.gradle

+ 23 - 2
build.gradle

@@ -10,13 +10,30 @@ ext {
     ]
 
     dependencies = [
-            "jsqlparser"    : "com.github.jsqlparser:jsqlparser:1.1",
+            "jsqlparser": "com.github.jsqlparser:jsqlparser:1.1",
             "mybatis-spring": "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
             "mybatis": "org.mybatis:mybatis:${mybatisVersion}",
+            "velocity":"org.apache.velocity:velocity-engine-core:2.0",
+            "slf4j-api":"org.slf4j:slf4j-api:1.7.25",
+            "junit":"junit:junit:4.12",
+            "commons-pool2":"org.apache.commons:commons-pool2:2.4.2",
+            "commons-dbcp2":"org.apache.commons:commons-dbcp2:2.1.1",
+            "mybatis-ehcache":"org.mybatis.caches:mybatis-ehcache:1.1.0",
+            "logback-classic":"ch.qos.logback:logback-classic:1.2.2",
+            "sqlserver":"com.microsoft.sqlserver:sqljdbc4:4.0",
+            "postgresql":"org.postgresql:postgresql:9.4.1212",
+            "oracle":"com.oracle:ojdbc14:10.2.0.5.0",
+            "h2":"com.h2database:h2:1.4.194",
+            "mysql":"mysql:mysql-connector-java:5.1.38",
+            "aspectjweaver":"org.aspectj:aspectjweaver:1.8.9",
+            "servlet-api":"javax.servlet:servlet-api:2.5",
+            "lombok":"org.projectlombok:lombok:1.16.16",
+            "hikaricp":"com.zaxxer:HikariCP:2.7.0",
+            "spring-test":"org.springframework:spring-test:${springVersion}",
+            "spring-webmvc":"org.springframework:spring-webmvc:${springVersion}",
             "spring-context-support":"org.springframework:spring-context-support:${springVersion}",
             "spring-jdbc":"org.springframework:spring-jdbc:${springVersion}",
             "spring-tx":"org.springframework:spring-tx:${springVersion}",
-            "velocity":"org.apache.velocity:velocity-engine-core:2.0",
     ]
 }
 
@@ -74,6 +91,10 @@ subprojects{
         archives javadocJar
     }
 
+    configurations {
+        compile.exclude module: "commons-logging"
+    }
+
     signing {
         sign configurations.archives
     }

+ 25 - 26
mybatis-plus-core/build.gradle

@@ -1,32 +1,31 @@
-
+def common = [
+    rootProject.ext.dependencies["spring-context-support"],
+    rootProject.ext.dependencies["spring-jdbc"]
+]
 dependencies {
     compile project(":mybatis-plus-api")
     compile rootProject.ext.dependencies["jsqlparser"]
     compile rootProject.ext.dependencies["mybatis-spring"]
     compile rootProject.ext.dependencies["mybatis"]
-    compileOnly rootProject.ext.dependencies["spring-context-support"]
-    compileOnly rootProject.ext.dependencies["spring-jdbc"]
-    testCompileOnly "javax.servlet:servlet-api:2.5"
-    testCompile "org.mybatis.caches:mybatis-ehcache:1.1.0"
-    testCompile "ch.qos.logback:logback-classic:1.2.2"
-    testCompile "junit:junit:4.12"
-    testCompile("org.apache.commons:commons-dbcp2:2.1.1") {
-        exclude(module: 'commons-logging')
-    }
-    testCompile "org.apache.commons:commons-pool2:2.4.2"
-    testCompile "com.microsoft.sqlserver:sqljdbc4:4.0"
-    testCompile "org.postgresql:postgresql:9.4.1212"
-    testCompile "com.oracle:ojdbc14:10.2.0.5.0"
-    testCompile "com.h2database:h2:1.4.194"
-    testCompile "mysql:mysql-connector-java:5.1.38"
-    testCompile "org.slf4j:slf4j-api:1.7.25"
-    testCompile "org.slf4j:jcl-over-slf4j:1.7.25"
-    testCompile "org.springframework:spring-test:${springVersion}"
-    testCompile "org.springframework:spring-webmvc:${springVersion}"
-    testCompile "org.aspectj:aspectjweaver:1.8.9"
-    testCompile "javax.servlet:servlet-api:2.5"
-    testCompile "org.projectlombok:lombok:1.16.16"
-    testCompile rootProject.ext.dependencies["spring-context-support"]
-    testCompile rootProject.ext.dependencies["spring-jdbc"]
-    testCompile "com.zaxxer:HikariCP:2.7.0"
+    compileOnly common
+    testCompile common
+    testCompileOnly rootProject.ext.dependencies["servlet-api"]
+    testCompile rootProject.ext.dependencies["mybatis-ehcache"]
+    testCompile rootProject.ext.dependencies["logback-classic"]
+    testCompile rootProject.ext.dependencies["junit"]
+    testCompile rootProject.ext.dependencies["commons-dbcp2"]
+    testCompile rootProject.ext.dependencies["commons-pool2"]
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["postgresql"]
+    testCompile rootProject.ext.dependencies["oracle"]
+    testCompile rootProject.ext.dependencies["h2"]
+    testCompile rootProject.ext.dependencies["mysql"]
+    testCompile rootProject.ext.dependencies["slf4j-api"]
+    testCompile rootProject.ext.dependencies["spring-test"]
+    testCompile rootProject.ext.dependencies["spring-webmvc"]
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["aspectjweaver"]
+    testCompile rootProject.ext.dependencies["servlet-api"]
+    testCompile rootProject.ext.dependencies["lombok"]
+    testCompile rootProject.ext.dependencies["hikaricp"]
 }

+ 0 - 465
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/AutoGenerator.java

@@ -1,465 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.ibatis.logging.Log;
-import org.apache.ibatis.logging.LogFactory;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.app.VelocityEngine;
-
-import com.baomidou.mybatisplus.generator.config.ConstVal;
-import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
-import com.baomidou.mybatisplus.generator.config.FileOutConfig;
-import com.baomidou.mybatisplus.generator.config.GlobalConfig;
-import com.baomidou.mybatisplus.generator.config.PackageConfig;
-import com.baomidou.mybatisplus.generator.config.StrategyConfig;
-import com.baomidou.mybatisplus.generator.config.TemplateConfig;
-import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
-import com.baomidou.mybatisplus.generator.config.po.TableField;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * 生成文件
- *
- * @author YangHu, tangguo
- * @since 2016-08-30
- */
-public class AutoGenerator {
-
-    private static final Log logger = LogFactory.getLog(AutoGenerator.class);
-
-    protected ConfigBuilder config;
-    protected InjectionConfig injectionConfig;
-    /**
-     * 数据源配置
-     */
-    private DataSourceConfig dataSource;
-    /**
-     * 数据库表配置
-     */
-    private StrategyConfig strategy;
-    /**
-     * 包 相关配置
-     */
-    private PackageConfig packageInfo;
-    /**
-     * 模板 相关配置
-     */
-    private TemplateConfig template;
-    /**
-     * 全局 相关配置
-     */
-    private GlobalConfig globalConfig;
-    /**
-     * velocity引擎
-     */
-    private VelocityEngine engine;
-
-    /**
-     * 生成代码
-     */
-    public void execute() {
-        logger.debug("==========================准备生成文件...==========================");
-        // 初始化配置
-        initConfig();
-        // 创建输出文件路径
-        mkdirs(config.getPathInfo());
-        // 获取上下文
-        Map<String, VelocityContext> ctxData = analyzeData(config);
-        // 循环生成文件
-        for (Map.Entry<String, VelocityContext> ctx : ctxData.entrySet()) {
-            batchOutput(ctx.getKey(), ctx.getValue());
-        }
-        // 打开输出目录
-        if (config.getGlobalConfig().isOpen()) {
-            try {
-                String osName = System.getProperty("os.name");
-                if (osName != null) {
-                    if (osName.contains("Mac")) {
-                        Runtime.getRuntime().exec("open " + config.getGlobalConfig().getOutputDir());
-                    } else if (osName.contains("Windows")) {
-                        Runtime.getRuntime().exec("cmd /c start " + config.getGlobalConfig().getOutputDir());
-                    } else {
-                        logger.debug("文件输出目录:" + config.getGlobalConfig().getOutputDir());
-                    }
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        logger.debug("==========================文件生成完成!!!==========================");
-    }
-
-    /**
-     * <p>
-     * 开放表信息、预留子类重写
-     * </p>
-     *
-     * @param config 配置信息
-     * @return
-     */
-    protected List<TableInfo> getAllTableInfoList(ConfigBuilder config) {
-        return config.getTableInfoList();
-    }
-
-    /**
-     * <p>
-     * 分析数据
-     * </p>
-     *
-     * @param config 总配置信息
-     * @return 解析数据结果集
-     */
-    private Map<String, VelocityContext> analyzeData(ConfigBuilder config) {
-        List<TableInfo> tableList = this.getAllTableInfoList(config);
-        Map<String, String> packageInfo = config.getPackageInfo();
-        Map<String, VelocityContext> ctxData = new HashMap<>();
-        String superEntityClass = getSuperClassName(config.getSuperEntityClass());
-        String superMapperClass = getSuperClassName(config.getSuperMapperClass());
-        String superServiceClass = getSuperClassName(config.getSuperServiceClass());
-        String superServiceImplClass = getSuperClassName(config.getSuperServiceImplClass());
-        String superControllerClass = getSuperClassName(config.getSuperControllerClass());
-        String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
-        VelocityContext ctx;
-        for (TableInfo tableInfo : tableList) {
-            ctx = new VelocityContext();
-            if (null != injectionConfig) {
-                /**
-                 * 注入自定义配置
-                 */
-                injectionConfig.initMap();
-                ctx.put("cfg", injectionConfig.getMap());
-            }
-            /* ---------- 添加导入包 ---------- */
-            if (config.getGlobalConfig().isActiveRecord()) {
-                // 开启 ActiveRecord 模式
-                tableInfo.setImportPackages("com.baomidou.mybatisplus.activerecord.Model");
-            }
-            if (tableInfo.isConvert()) {
-                // 表注解
-                tableInfo.setImportPackages("com.baomidou.mybatisplus.annotations.TableName");
-            }
-            if (tableInfo.isLogicDelete(config.getStrategyConfig().getLogicDeleteFieldName())) {
-                // 逻辑删除注解
-                tableInfo.setImportPackages("com.baomidou.mybatisplus.annotations.TableLogic");
-            }
-            if (StringUtils.isNotEmpty(config.getStrategyConfig().getVersionFieldName())) {
-                // 乐观锁注解
-                tableInfo.setImportPackages("com.baomidou.mybatisplus.annotations.Version");
-            }
-            if (StringUtils.isNotEmpty(config.getSuperEntityClass())) {
-                // 父实体
-                tableInfo.setImportPackages(config.getSuperEntityClass());
-            } else {
-                tableInfo.setImportPackages("java.io.Serializable");
-            }
-            // Boolean类型is前缀处理
-            if (config.getStrategyConfig().isEntityBooleanColumnRemoveIsPrefix()) {
-                for (TableField field : tableInfo.getFields()) {
-                    if (field.getPropertyType().equalsIgnoreCase("boolean")) {
-                        if (field.getPropertyName().startsWith("is")) {
-                            field.setPropertyName(config.getStrategyConfig(),
-                                    StringUtils.removePrefixAfterPrefixToLower(field.getPropertyName(), 2));
-                        }
-                    }
-                }
-            }
-            // RequestMapping 连字符风格 user-info
-            if (config.getStrategyConfig().isControllerMappingHyphenStyle()) {
-                ctx.put("controllerMappingHyphenStyle", config.getStrategyConfig().isControllerMappingHyphenStyle());
-                ctx.put("controllerMappingHyphen", StringUtils.camelToHyphen(tableInfo.getEntityPath()));
-            }
-
-            ctx.put("restControllerStyle", config.getStrategyConfig().isRestControllerStyle());
-            ctx.put("package", packageInfo);
-            ctx.put("author", config.getGlobalConfig().getAuthor());
-            ctx.put("logicDeleteFieldName", config.getStrategyConfig().getLogicDeleteFieldName());
-            ctx.put("versionFieldName", config.getStrategyConfig().getVersionFieldName());
-            ctx.put("activeRecord", config.getGlobalConfig().isActiveRecord());
-            ctx.put("kotlin", config.getGlobalConfig().isKotlin());
-            ctx.put("date", date);
-            ctx.put("table", tableInfo);
-            ctx.put("enableCache", config.getGlobalConfig().isEnableCache());
-            ctx.put("baseResultMap", config.getGlobalConfig().isBaseResultMap());
-            ctx.put("baseColumnList", config.getGlobalConfig().isBaseColumnList());
-            ctx.put("entity", tableInfo.getEntityName());
-            ctx.put("entityColumnConstant", config.getStrategyConfig().isEntityColumnConstant());
-            ctx.put("entityBuilderModel", config.getStrategyConfig().isEntityBuilderModel());
-            ctx.put("entityLombokModel", config.getStrategyConfig().isEntityLombokModel());
-            ctx.put("entityBooleanColumnRemoveIsPrefix", config.getStrategyConfig().isEntityBooleanColumnRemoveIsPrefix());
-            ctx.put("superEntityClass", superEntityClass);
-            ctx.put("superMapperClassPackage", config.getSuperMapperClass());
-            ctx.put("superMapperClass", superMapperClass);
-            ctx.put("superServiceClassPackage", config.getSuperServiceClass());
-            ctx.put("superServiceClass", superServiceClass);
-            ctx.put("superServiceImplClassPackage", config.getSuperServiceImplClass());
-            ctx.put("superServiceImplClass", superServiceImplClass);
-            ctx.put("superControllerClassPackage", config.getSuperControllerClass());
-            ctx.put("superControllerClass", superControllerClass);
-            ctxData.put(tableInfo.getEntityName(), ctx);
-        }
-        return ctxData;
-    }
-
-    /**
-     * <p>
-     * 获取类名
-     * </p>
-     *
-     * @param classPath
-     * @return
-     */
-    private String getSuperClassName(String classPath) {
-        if (StringUtils.isEmpty(classPath)) {
-            return null;
-        }
-        return classPath.substring(classPath.lastIndexOf(".") + 1);
-    }
-
-    /**
-     * <p>
-     * 处理输出目录
-     * </p>
-     *
-     * @param pathInfo 路径信息
-     */
-    private void mkdirs(Map<String, String> pathInfo) {
-        for (Map.Entry<String, String> entry : pathInfo.entrySet()) {
-            File dir = new File(entry.getValue());
-            if (!dir.exists()) {
-                boolean result = dir.mkdirs();
-                if (result) {
-                    logger.debug("创建目录: [" + entry.getValue() + "]");
-                }
-            }
-        }
-    }
-
-    /**
-     * <p>
-     * 合成上下文与模板
-     * </p>
-     *
-     * @param context vm上下文
-     */
-    private void batchOutput(String entityName, VelocityContext context) {
-        try {
-            TableInfo tableInfo = (TableInfo) context.get("table");
-            Map<String, String> pathInfo = config.getPathInfo();
-            String entityFile = String.format((pathInfo.get(ConstVal.ENTITY_PATH) + File.separator + "%s" + this.suffixJavaOrKt()), entityName);
-            String mapperFile = String.format((pathInfo.get(ConstVal.MAPPER_PATH) + File.separator + tableInfo.getMapperName() + this.suffixJavaOrKt()), entityName);
-            String xmlFile = String.format((pathInfo.get(ConstVal.XML_PATH) + File.separator + tableInfo.getXmlName() + ConstVal.XML_SUFFIX), entityName);
-            String serviceFile = String.format((pathInfo.get(ConstVal.SERIVCE_PATH) + File.separator + tableInfo.getServiceName() + this.suffixJavaOrKt()), entityName);
-            String implFile = String.format((pathInfo.get(ConstVal.SERVICEIMPL_PATH) + File.separator + tableInfo.getServiceImplName() + this.suffixJavaOrKt()), entityName);
-            String controllerFile = String.format((pathInfo.get(ConstVal.CONTROLLER_PATH) + File.separator + tableInfo.getControllerName() + this.suffixJavaOrKt()), entityName);
-
-            TemplateConfig template = config.getTemplate();
-
-            // 根据override标识来判断是否需要创建文件
-            if (isCreate(entityFile)) {
-                vmToFile(context, template.getEntity(config.getGlobalConfig().isKotlin()), entityFile);
-            }
-            if (isCreate(mapperFile)) {
-                vmToFile(context, template.getMapper(), mapperFile);
-            }
-            if (isCreate(xmlFile)) {
-                vmToFile(context, template.getXml(), xmlFile);
-            }
-            if (isCreate(serviceFile)) {
-                vmToFile(context, template.getService(), serviceFile);
-            }
-            if (isCreate(implFile)) {
-                vmToFile(context, template.getServiceImpl(), implFile);
-            }
-            if (isCreate(controllerFile)) {
-                vmToFile(context, template.getController(), controllerFile);
-            }
-            if (injectionConfig != null) {
-                /**
-                 * 输出自定义文件内容
-                 */
-                List<FileOutConfig> focList = injectionConfig.getFileOutConfigList();
-                if (CollectionUtils.isNotEmpty(focList)) {
-                    for (FileOutConfig foc : focList) {
-                        // 判断自定义文件是否存在
-                        if (isCreate(foc.outputFile(tableInfo))) {
-                            vmToFile(context, foc.getTemplatePath(), foc.outputFile(tableInfo));
-                        }
-                    }
-                }
-            }
-
-        } catch (IOException e) {
-            logger.error("无法创建文件,请检查配置信息!", e);
-        }
-    }
-
-    /**
-     * 文件后缀
-     */
-    protected String suffixJavaOrKt() {
-        return config.getGlobalConfig().isKotlin() ? ConstVal.KT_SUFFIX : ConstVal.JAVA_SUFFIX;
-    }
-
-    /**
-     * <p>
-     * 将模板转化成为文件
-     * </p>
-     *
-     * @param context      内容对象
-     * @param templatePath 模板文件
-     * @param outputFile   文件生成的目录
-     */
-    private void vmToFile(VelocityContext context, String templatePath, String outputFile) throws IOException {
-        if (StringUtils.isEmpty(templatePath)) {
-            return;
-        }
-        VelocityEngine velocity = getVelocityEngine();
-        Template template = velocity.getTemplate(templatePath, ConstVal.UTF8);
-        File file = new File(outputFile);
-        if (!file.getParentFile().exists()) {
-            // 如果文件所在的目录不存在,则创建目录
-            if (!file.getParentFile().mkdirs()) {
-                logger.debug("创建文件所在的目录失败!");
-                return;
-            }
-        }
-        FileOutputStream fos = new FileOutputStream(outputFile);
-        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos, ConstVal.UTF8));
-        template.merge(context, writer);
-        writer.close();
-        logger.debug("模板:" + templatePath + ";  文件:" + outputFile);
-    }
-
-    /**
-     * 设置模版引擎,主要指向获取模版路径
-     */
-    private VelocityEngine getVelocityEngine() {
-        if (engine == null) {
-            Properties p = new Properties();
-            p.setProperty(ConstVal.VM_LOADPATH_KEY, ConstVal.VM_LOADPATH_VALUE);
-            p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "");
-            p.setProperty(Velocity.ENCODING_DEFAULT, ConstVal.UTF8);
-            p.setProperty(Velocity.INPUT_ENCODING, ConstVal.UTF8);
-            p.setProperty("file.resource.loader.unicode", "true");
-            engine = new VelocityEngine(p);
-        }
-        return engine;
-    }
-
-    /**
-     * 检测文件是否存在
-     *
-     * @return 是否
-     */
-    private boolean isCreate(String filePath) {
-        File file = new File(filePath);
-        return !file.exists() || config.getGlobalConfig().isFileOverride();
-    }
-
-    // ==================================  相关配置  ==================================
-
-    /**
-     * 初始化配置
-     */
-    protected void initConfig() {
-        if (null == config) {
-            config = new ConfigBuilder(packageInfo, dataSource, strategy, template, globalConfig);
-            if (null != injectionConfig) {
-                injectionConfig.setConfig(config);
-            }
-        }
-    }
-
-    public DataSourceConfig getDataSource() {
-        return dataSource;
-    }
-
-    public AutoGenerator setDataSource(DataSourceConfig dataSource) {
-        this.dataSource = dataSource;
-        return this;
-    }
-
-    public StrategyConfig getStrategy() {
-        return strategy;
-    }
-
-    public AutoGenerator setStrategy(StrategyConfig strategy) {
-        this.strategy = strategy;
-        return this;
-    }
-
-    public PackageConfig getPackageInfo() {
-        return packageInfo;
-    }
-
-    public AutoGenerator setPackageInfo(PackageConfig packageInfo) {
-        this.packageInfo = packageInfo;
-        return this;
-    }
-
-    public TemplateConfig getTemplate() {
-        return template;
-    }
-
-    public AutoGenerator setTemplate(TemplateConfig template) {
-        this.template = template;
-        return this;
-    }
-
-    public ConfigBuilder getConfig() {
-        return config;
-    }
-
-    public AutoGenerator setConfig(ConfigBuilder config) {
-        this.config = config;
-        return this;
-    }
-
-    public GlobalConfig getGlobalConfig() {
-        return globalConfig;
-    }
-
-    public AutoGenerator setGlobalConfig(GlobalConfig globalConfig) {
-        this.globalConfig = globalConfig;
-        return this;
-    }
-
-    public InjectionConfig getCfg() {
-        return injectionConfig;
-    }
-
-    public AutoGenerator setCfg(InjectionConfig injectionConfig) {
-        this.injectionConfig = injectionConfig;
-        return this;
-    }
-}

+ 0 - 81
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/InjectionConfig.java

@@ -1,81 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator;
-
-import java.util.List;
-import java.util.Map;
-
-import com.baomidou.mybatisplus.generator.config.FileOutConfig;
-import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
-
-/**
- * <p>
- * 抽象的对外接口
- * </p>
- *
- * @author hubin
- * @since 2016-12-07
- */
-public abstract class InjectionConfig {
-
-    /**
-     * 全局配置
-     */
-    private ConfigBuilder config;
-
-    /**
-     * 自定义返回配置 Map 对象
-     */
-    private Map<String, Object> map;
-
-    /**
-     * 自定义输出文件
-     */
-    private List<FileOutConfig> fileOutConfigList;
-
-    /**
-     * 注入自定义 Map 对象
-     */
-    public abstract void initMap();
-
-    public ConfigBuilder getConfig() {
-        return config;
-    }
-
-    public InjectionConfig setConfig(ConfigBuilder config) {
-        this.config = config;
-        return this;
-    }
-
-    public Map<String, Object> getMap() {
-        return map;
-    }
-
-    public InjectionConfig setMap(Map<String, Object> map) {
-        this.map = map;
-        return this;
-    }
-
-    public List<FileOutConfig> getFileOutConfigList() {
-        return fileOutConfigList;
-    }
-
-    public InjectionConfig setFileOutConfigList(List<FileOutConfig> fileOutConfigList) {
-        this.fileOutConfigList = fileOutConfigList;
-        return this;
-    }
-
-}

+ 0 - 67
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/ConstVal.java

@@ -1,67 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-import java.nio.charset.Charset;
-
-/**
- * 定义常量
- *
- * @author YangHu, tangguo
- * @since 2016/8/31
- */
-public class ConstVal {
-
-    public static final String MODULENAME = "ModuleName";
-
-    public static final String ENTITY = "Entity";
-    public static final String SERIVCE = "Service";
-    public static final String SERVICEIMPL = "ServiceImpl";
-    public static final String MAPPER = "Mapper";
-    public static final String XML = "Xml";
-    public static final String CONTROLLER = "Controller";
-
-    public static final String ENTITY_PATH = "entity_path";
-    public static final String SERIVCE_PATH = "serivce_path";
-    public static final String SERVICEIMPL_PATH = "serviceimpl_path";
-    public static final String MAPPER_PATH = "mapper_path";
-    public static final String XML_PATH = "xml_path";
-    public static final String CONTROLLER_PATH = "controller_path";
-
-    public static final String JAVA_TMPDIR = "java.io.tmpdir";
-    public static final String UTF8 = Charset.forName("UTF-8").name();
-    public static final String UNDERLINE = "_";
-
-    public static final String JAVA_SUFFIX = ".java";
-    public static final String KT_SUFFIX = ".kt";
-    public static final String XML_SUFFIX = ".xml";
-
-    public static final String TEMPLATE_ENTITY_JAVA = "/templates/entity.java.vm";
-    public static final String TEMPLATE_ENTITY_KT = "/templates/entity.kt.vm";
-    public static final String TEMPLATE_MAPPER = "/templates/mapper.java.vm";
-    public static final String TEMPLATE_XML = "/templates/mapper.xml.vm";
-    public static final String TEMPLATE_SERVICE = "/templates/service.java.vm";
-    public static final String TEMPLATE_SERVICEIMPL = "/templates/serviceImpl.java.vm";
-    public static final String TEMPLATE_CONTROLLER = "/templates/controller.java.vm";
-
-    public static final String VM_LOADPATH_KEY = "file.resource.loader.class";
-    public static final String VM_LOADPATH_VALUE = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";
-
-    public static final String SUPERD_MAPPER_CLASS = "com.baomidou.mybatisplus.mapper.BaseMapper";
-    public static final String SUPERD_SERVICE_CLASS = "com.baomidou.mybatisplus.service.IService";
-    public static final String SUPERD_SERVICEIMPL_CLASS = "com.baomidou.mybatisplus.service.impl.ServiceImpl";
-
-}

+ 0 - 179
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/DataSourceConfig.java

@@ -1,179 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import com.baomidou.mybatisplus.exceptions.MybatisPlusException;
-import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
-import com.baomidou.mybatisplus.generator.config.converts.OracleTypeConvert;
-import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert;
-import com.baomidou.mybatisplus.generator.config.converts.SqlServerTypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DbType;
-
-/**
- * <p>
- * 数据库配置
- * </p>
- *
- * @author YangHu
- * @since 2016/8/30
- */
-public class DataSourceConfig {
-
-    /**
-     * 数据库类型
-     */
-    private DbType dbType;
-    /**
-     * PostgreSQL schemaname
-     */
-    private String schemaname = "public";
-    /**
-     * 类型转换
-     */
-    private ITypeConvert typeConvert;
-    /**
-     * 驱动连接的URL
-     */
-    private String url;
-    /**
-     * 驱动名称
-     */
-    private String driverName;
-    /**
-     * 数据库连接用户名
-     */
-    private String username;
-    /**
-     * 数据库连接密码
-     */
-    private String password;
-
-    /**
-     * 判断数据库类型
-     *
-     * @return 类型枚举值
-     */
-    public DbType getDbType() {
-        if (null == dbType) {
-            if (driverName.contains("mysql")) {
-                dbType = DbType.MYSQL;
-            } else if (driverName.contains("oracle")) {
-                dbType = DbType.ORACLE;
-            } else if (driverName.contains("postgresql")) {
-                dbType = DbType.POSTGRE_SQL;
-            } else {
-                throw new MybatisPlusException("Unknown type of database!");
-            }
-        }
-        return dbType;
-    }
-
-    public DataSourceConfig setDbType(DbType dbType) {
-        this.dbType = dbType;
-        return this;
-    }
-
-    public String getSchemaname() {
-        return schemaname;
-    }
-
-    public void setSchemaname(String schemaname) {
-        this.schemaname = schemaname;
-    }
-
-    public ITypeConvert getTypeConvert() {
-        if (null == typeConvert) {
-            switch (getDbType()) {
-                case ORACLE:
-                    typeConvert = new OracleTypeConvert();
-                    break;
-                case SQL_SERVER:
-                    typeConvert = new SqlServerTypeConvert();
-                    break;
-                case POSTGRE_SQL:
-                    typeConvert = new PostgreSqlTypeConvert();
-                    break;
-                default:
-                    // 默认 MYSQL
-                    typeConvert = new MySqlTypeConvert();
-                    break;
-            }
-        }
-        return typeConvert;
-    }
-
-    public DataSourceConfig setTypeConvert(ITypeConvert typeConvert) {
-        this.typeConvert = typeConvert;
-        return this;
-    }
-
-    /**
-     * 创建数据库连接对象
-     *
-     * @return Connection
-     */
-    public Connection getConn() {
-        Connection conn = null;
-        try {
-            Class.forName(driverName);
-            conn = DriverManager.getConnection(url, username, password);
-        } catch (ClassNotFoundException | SQLException e) {
-            e.printStackTrace();
-        }
-        return conn;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public DataSourceConfig setUrl(String url) {
-        this.url = url;
-        return this;
-    }
-
-    public String getDriverName() {
-        return driverName;
-    }
-
-    public DataSourceConfig setDriverName(String driverName) {
-        this.driverName = driverName;
-        return this;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public DataSourceConfig setUsername(String username) {
-        this.username = username;
-        return this;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public DataSourceConfig setPassword(String password) {
-        this.password = password;
-        return this;
-    }
-
-}

+ 0 - 57
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/FileOutConfig.java

@@ -1,57 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-
-/**
- * <p>
- * 输出文件配置
- * </p>
- *
- * @author hubin
- * @since 2017-01-18
- */
-public abstract class FileOutConfig {
-
-    /**
-     * 模板
-     */
-    private String templatePath;
-
-    public FileOutConfig() {
-        // to do nothing
-    }
-
-    public FileOutConfig(String templatePath) {
-        this.templatePath = templatePath;
-    }
-
-    /**
-     * 输出文件
-     */
-    public abstract String outputFile(TableInfo tableInfo);
-
-    public String getTemplatePath() {
-        return templatePath;
-    }
-
-    public FileOutConfig setTemplatePath(String templatePath) {
-        this.templatePath = templatePath;
-        return this;
-    }
-
-}

+ 0 - 206
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/GlobalConfig.java

@@ -1,206 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-/**
- * <p>
- * 全局配置
- * </p>
- *
- * @author hubin
- * @since 2016-12-02
- */
-public class GlobalConfig {
-
-    /**
-     * 生成文件的输出目录【默认 D 盘根目录】
-     */
-    private String outputDir = "D://";
-
-    /**
-     * 是否覆盖已有文件
-     */
-    private boolean fileOverride = false;
-
-    /**
-     * 是否打开输出目录
-     */
-    private boolean open = true;
-
-    /**
-     * 是否在xml中添加二级缓存配置
-     */
-    private boolean enableCache = true;
-
-    /**
-     * 开发人员
-     */
-    private String author;
-
-    /**
-     * 开启 Kotlin 模式
-     */
-    private boolean kotlin = false;
-
-    /**
-     * 开启 ActiveRecord 模式
-     */
-    private boolean activeRecord = true;
-
-    /**
-     * 开启 BaseResultMap
-     */
-    private boolean baseResultMap = false;
-
-    /**
-     * 开启 baseColumnList
-     */
-    private boolean baseColumnList = false;
-    /**
-     * 各层文件名称方式,例如: %Action 生成 UserAction
-     */
-    private String mapperName;
-    private String xmlName;
-    private String serviceName;
-    private String serviceImplName;
-    private String controllerName;
-
-    public String getOutputDir() {
-        return outputDir;
-    }
-
-    public GlobalConfig setOutputDir(String outputDir) {
-        this.outputDir = outputDir;
-        return this;
-    }
-
-    public boolean isFileOverride() {
-        return fileOverride;
-    }
-
-    public GlobalConfig setFileOverride(boolean fileOverride) {
-        this.fileOverride = fileOverride;
-        return this;
-    }
-
-    public boolean isOpen() {
-        return open;
-    }
-
-    public GlobalConfig setOpen(boolean open) {
-        this.open = open;
-        return this;
-    }
-
-    public boolean isEnableCache() {
-        return enableCache;
-    }
-
-    public GlobalConfig setEnableCache(boolean enableCache) {
-        this.enableCache = enableCache;
-        return this;
-    }
-
-    public String getAuthor() {
-        return author;
-    }
-
-    public GlobalConfig setAuthor(String author) {
-        this.author = author;
-        return this;
-    }
-
-    public boolean isKotlin() {
-        return kotlin;
-    }
-
-    public GlobalConfig setKotlin(boolean kotlin) {
-        this.kotlin = kotlin;
-        return this;
-    }
-
-    public boolean isActiveRecord() {
-        return activeRecord;
-    }
-
-    public GlobalConfig setActiveRecord(boolean activeRecord) {
-        this.activeRecord = activeRecord;
-        return this;
-    }
-
-    public boolean isBaseResultMap() {
-        return baseResultMap;
-    }
-
-    public GlobalConfig setBaseResultMap(boolean baseResultMap) {
-        this.baseResultMap = baseResultMap;
-        return this;
-    }
-
-    public boolean isBaseColumnList() {
-        return baseColumnList;
-    }
-
-    public GlobalConfig setBaseColumnList(boolean baseColumnList) {
-        this.baseColumnList = baseColumnList;
-        return this;
-    }
-
-    public String getMapperName() {
-        return mapperName;
-    }
-
-    public GlobalConfig setMapperName(String mapperName) {
-        this.mapperName = mapperName;
-        return this;
-    }
-
-    public String getXmlName() {
-        return xmlName;
-    }
-
-    public GlobalConfig setXmlName(String xmlName) {
-        this.xmlName = xmlName;
-        return this;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public GlobalConfig setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-        return this;
-    }
-
-    public String getServiceImplName() {
-        return serviceImplName;
-    }
-
-    public GlobalConfig setServiceImplName(String serviceImplName) {
-        this.serviceImplName = serviceImplName;
-        return this;
-    }
-
-    public String getControllerName() {
-        return controllerName;
-    }
-
-    public GlobalConfig setControllerName(String controllerName) {
-        this.controllerName = controllerName;
-        return this;
-    }
-}

+ 0 - 146
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/PackageConfig.java

@@ -1,146 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * <p>
- * 跟包相关的配置项
- *
- * @author YangHu, tangguo, hubin
- * @since 2016-08-30
- */
-public class PackageConfig {
-
-    /**
-     * 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
-     */
-    private String parent = "com.baomidou";
-
-    /**
-     * 父包模块名。
-     */
-    private String moduleName = null;
-
-    /**
-     * Entity包名
-     */
-    private String entity = "entity";
-
-    /**
-     * Service包名
-     */
-    private String service = "service";
-
-    /**
-     * Service Impl包名
-     */
-    private String serviceImpl = "service.impl";
-    /**
-     * Mapper包名
-     */
-    private String mapper = "mapper";
-
-    /**
-     * Mapper XML包名
-     */
-    private String xml = "mapper.xml";
-
-    /**
-     * Controller包名
-     */
-    private String controller = "web";
-
-    public String getParent() {
-        if (StringUtils.isNotEmpty(moduleName)) {
-            return parent + "." + moduleName;
-        }
-        return parent;
-    }
-
-    public PackageConfig setParent(String parent) {
-        this.parent = parent;
-        return this;
-    }
-
-    public String getModuleName() {
-        return moduleName;
-    }
-
-    public PackageConfig setModuleName(String moduleName) {
-        this.moduleName = moduleName;
-        return this;
-    }
-
-    public String getEntity() {
-        return entity;
-    }
-
-    public PackageConfig setEntity(String entity) {
-        this.entity = entity;
-        return this;
-    }
-
-    public String getService() {
-        return service;
-    }
-
-    public PackageConfig setService(String service) {
-        this.service = service;
-        return this;
-    }
-
-    public String getServiceImpl() {
-        return serviceImpl;
-    }
-
-    public PackageConfig setServiceImpl(String serviceImpl) {
-        this.serviceImpl = serviceImpl;
-        return this;
-    }
-
-    public String getMapper() {
-        return mapper;
-    }
-
-    public PackageConfig setMapper(String mapper) {
-        this.mapper = mapper;
-        return this;
-    }
-
-    public String getXml() {
-        return xml;
-    }
-
-    public PackageConfig setXml(String xml) {
-        this.xml = xml;
-        return this;
-    }
-
-    public String getController() {
-        if (StringUtils.isEmpty(controller)) {
-            return "web";
-        }
-        return controller;
-    }
-
-    public PackageConfig setController(String controller) {
-        this.controller = controller;
-        return this;
-    }
-
-}

+ 0 - 389
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/StrategyConfig.java

@@ -1,389 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-import java.util.List;
-
-import com.baomidou.mybatisplus.generator.config.po.TableFill;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * <p>
- * 策略配置项
- * </p>
- *
- * @author YangHu, tangguo, hubin
- * @since 2016/8/30
- */
-public class StrategyConfig {
-
-    /**
-     * 表名、字段名、是否使用下划线命名(默认 false)
-     */
-    public static boolean DB_COLUMN_UNDERLINE = false;
-
-    /**
-     * 是否大写命名
-     */
-    private boolean isCapitalMode = false;
-
-    /**
-     * 数据库表映射到实体的命名策略
-     */
-    private NamingStrategy naming = NamingStrategy.nochange;
-
-    /**
-     * 表前缀
-     */
-    private String[] tablePrefix;
-
-    /**
-     * 自定义继承的Entity类全称,带包名
-     */
-    private String superEntityClass;
-
-    /**
-     * 自定义基础的Entity类,公共字段
-     */
-    private String[] superEntityColumns;
-
-    /**
-     * 自定义继承的Mapper类全称,带包名
-     */
-    private String superMapperClass = ConstVal.SUPERD_MAPPER_CLASS;
-
-    /**
-     * 自定义继承的Service类全称,带包名
-     */
-    private String superServiceClass = ConstVal.SUPERD_SERVICE_CLASS;
-
-    /**
-     * 自定义继承的ServiceImpl类全称,带包名
-     */
-    private String superServiceImplClass = ConstVal.SUPERD_SERVICEIMPL_CLASS;
-
-    /**
-     * 自定义继承的Controller类全称,带包名
-     */
-    private String superControllerClass;
-
-    /*
-     * 需要包含的表名(与exclude二选一配置)
-     */
-    private String[] include = null;
-
-    /**
-     * 需要排除的表名
-     */
-    private String[] exclude = null;
-    /**
-     * 【实体】是否生成字段常量(默认 false)<br>
-     * -----------------------------------<br>
-     * public static final String ID = "test_id";
-     */
-    private boolean entityColumnConstant = false;
-
-    /**
-     * 【实体】是否为构建者模型(默认 false)<br>
-     * -----------------------------------<br>
-     * public User setName(String name) { this.name = name; return this; }
-     */
-    private boolean entityBuilderModel = false;
-
-    /**
-     * 【实体】是否为lombok模型(默认 false)<br>
-     * <a href="https://projectlombok.org/">document</a>
-     */
-    private boolean entityLombokModel = false;
-
-    /**
-     * Boolean类型字段是否移除is前缀(默认 false)<br>
-     * 比如 : 数据库字段名称 : 'is_xxx',类型为 : tinyint. 在映射实体的时候则会去掉is,在实体类中映射最终结果为 xxx
-     */
-    private boolean entityBooleanColumnRemoveIsPrefix = false;
-    /**
-     * 生成 <code>@RestController</code> 控制器
-     * <pre>
-     *      <code>@Controller</code> -> <code>@RestController</code>
-     * </pre>
-     */
-    private boolean restControllerStyle = false;
-    /**
-     * 驼峰转连字符
-     * <pre>
-     *      <code>@RequestMapping("/managerUserActionHistory")</code> -> <code>@RequestMapping("/manager-user-action-history")</code>
-     * </pre>
-     */
-    private boolean controllerMappingHyphenStyle = false;
-
-    /**
-     * 乐观锁属性名称
-     */
-    private String versionFieldName;
-
-    /**
-     * 逻辑删除属性名称
-     */
-    private String logicDeleteFieldName;
-
-    /**
-     * 表填充字段
-     */
-    private List<TableFill> tableFillList = null;
-
-    public StrategyConfig setDbColumnUnderline(boolean dbColumnUnderline) {
-        DB_COLUMN_UNDERLINE = dbColumnUnderline;
-        return this;
-    }
-
-    /**
-     * <p>
-     * 大写命名、字段符合大写字母数字下划线命名
-     * </p>
-     *
-     * @param word 待判断字符串
-     * @return
-     */
-    public boolean isCapitalModeNaming(String word) {
-        return isCapitalMode && StringUtils.isCapitalMode(word);
-    }
-
-    /**
-     * <p>
-     * 表名称包含指定前缀
-     * </p>
-     *
-     * @param tableName 表名称
-     * @return
-     */
-    public boolean containsTablePrefix(String tableName) {
-        if (null != tableName) {
-            String[] tps = getTablePrefix();
-            if (null != tps) {
-                for (String tp : tps) {
-                    if (tableName.contains(tp)) {
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    public boolean isCapitalMode() {
-        return isCapitalMode;
-    }
-
-    public StrategyConfig setCapitalMode(boolean isCapitalMode) {
-        this.isCapitalMode = isCapitalMode;
-        return this;
-    }
-
-    public NamingStrategy getNaming() {
-        return naming;
-    }
-
-    public StrategyConfig setNaming(NamingStrategy naming) {
-        this.naming = naming;
-        return this;
-    }
-
-    public String[] getTablePrefix() {
-        return tablePrefix;
-    }
-
-    public StrategyConfig setTablePrefix(String... tablePrefix) {
-        this.tablePrefix = tablePrefix;
-        return this;
-    }
-
-    public String getSuperEntityClass() {
-        return superEntityClass;
-    }
-
-    public StrategyConfig setSuperEntityClass(String superEntityClass) {
-        this.superEntityClass = superEntityClass;
-        return this;
-    }
-
-    public boolean includeSuperEntityColumns(String fieldName) {
-        if (null != superEntityColumns) {
-            for (String column : superEntityColumns) {
-                if (column.equals(fieldName)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    public String[] getSuperEntityColumns() {
-        return superEntityColumns;
-    }
-
-    public StrategyConfig setSuperEntityColumns(String... superEntityColumns) {
-        this.superEntityColumns = superEntityColumns;
-        return this;
-    }
-
-    public String getSuperMapperClass() {
-        return superMapperClass;
-    }
-
-    public StrategyConfig setSuperMapperClass(String superMapperClass) {
-        this.superMapperClass = superMapperClass;
-        return this;
-    }
-
-    public String getSuperServiceClass() {
-        return superServiceClass;
-    }
-
-    public StrategyConfig setSuperServiceClass(String superServiceClass) {
-        this.superServiceClass = superServiceClass;
-        return this;
-    }
-
-    public String getSuperServiceImplClass() {
-        return superServiceImplClass;
-    }
-
-    public StrategyConfig setSuperServiceImplClass(String superServiceImplClass) {
-        this.superServiceImplClass = superServiceImplClass;
-        return this;
-    }
-
-    public String getSuperControllerClass() {
-        return superControllerClass;
-    }
-
-    public StrategyConfig setSuperControllerClass(String superControllerClass) {
-        this.superControllerClass = superControllerClass;
-        return this;
-    }
-
-    public String[] getInclude() {
-        return include;
-    }
-
-    public StrategyConfig setInclude(String... include) {
-        this.include = include;
-        return this;
-    }
-
-    public String[] getExclude() {
-        return exclude;
-    }
-
-    public StrategyConfig setExclude(String... exclude) {
-        this.exclude = exclude;
-        return this;
-    }
-
-    public boolean isEntityColumnConstant() {
-        return entityColumnConstant;
-    }
-
-    public StrategyConfig setEntityColumnConstant(boolean entityColumnConstant) {
-        this.entityColumnConstant = entityColumnConstant;
-        return this;
-    }
-
-    public boolean isEntityBuilderModel() {
-        return entityBuilderModel;
-    }
-
-    public StrategyConfig setEntityBuilderModel(boolean entityBuilderModel) {
-        this.entityBuilderModel = entityBuilderModel;
-        return this;
-    }
-
-    public boolean isEntityLombokModel() {
-        return entityLombokModel;
-    }
-
-    public StrategyConfig setEntityLombokModel(boolean entityLombokModel) {
-        this.entityLombokModel = entityLombokModel;
-        return this;
-    }
-
-    public boolean isEntityBooleanColumnRemoveIsPrefix() {
-        return entityBooleanColumnRemoveIsPrefix;
-    }
-
-    public StrategyConfig setEntityBooleanColumnRemoveIsPrefix(boolean entityBooleanColumnRemoveIsPrefix) {
-        this.entityBooleanColumnRemoveIsPrefix = entityBooleanColumnRemoveIsPrefix;
-        return this;
-    }
-
-    public boolean isRestControllerStyle() {
-        return restControllerStyle;
-    }
-
-    public StrategyConfig setRestControllerStyle(boolean restControllerStyle) {
-        this.restControllerStyle = restControllerStyle;
-        return this;
-    }
-
-    public boolean isControllerMappingHyphenStyle() {
-        return controllerMappingHyphenStyle;
-    }
-
-    public StrategyConfig setControllerMappingHyphenStyle(boolean controllerMappingHyphenStyle) {
-        this.controllerMappingHyphenStyle = controllerMappingHyphenStyle;
-        return this;
-    }
-
-    public String getLogicDeleteFieldName() {
-        return logicDeleteFieldName;
-    }
-
-    /**
-     * 设置逻辑删除字段
-     *
-     * @param logicDeleteFieldName 数据库字段
-     * @return
-     */
-    public StrategyConfig setLogicDeleteFieldName(String logicDeleteFieldName) {
-        this.logicDeleteFieldName = logicDeleteFieldName;
-        return this;
-    }
-
-    public String getVersionFieldName() {
-        return versionFieldName;
-    }
-
-    /**
-     * 设置乐观锁字段
-     *
-     * @param versionFieldName 数据库字段
-     * @return
-     */
-    public StrategyConfig setVersionFieldName(String versionFieldName) {
-        this.versionFieldName = versionFieldName;
-        return this;
-    }
-
-    public List<TableFill> getTableFillList() {
-        return tableFillList;
-    }
-
-    public StrategyConfig setTableFillList(List<TableFill> tableFillList) {
-        this.tableFillList = tableFillList;
-        return this;
-    }
-}

+ 0 - 94
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java

@@ -1,94 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config;
-
-/**
- * <p>
- * 模板路径配置项
- * </p>
- *
- * @author tzg hubin
- * @since 2017-06-17
- */
-public class TemplateConfig {
-
-    private String entity = ConstVal.TEMPLATE_ENTITY_JAVA;
-
-    private String service = ConstVal.TEMPLATE_SERVICE;
-
-    private String serviceImpl = ConstVal.TEMPLATE_SERVICEIMPL;
-
-    private String mapper = ConstVal.TEMPLATE_MAPPER;
-
-    private String xml = ConstVal.TEMPLATE_XML;
-
-    private String controller = ConstVal.TEMPLATE_CONTROLLER;
-
-    public String getEntity(boolean kotlin) {
-        return kotlin ? ConstVal.TEMPLATE_ENTITY_KT : entity;
-    }
-
-    public TemplateConfig setEntity(String entity) {
-        this.entity = entity;
-        return this;
-    }
-
-    public String getService() {
-        return service;
-    }
-
-    public TemplateConfig setService(String service) {
-        this.service = service;
-        return this;
-    }
-
-    public String getServiceImpl() {
-        return serviceImpl;
-    }
-
-    public TemplateConfig setServiceImpl(String serviceImpl) {
-        this.serviceImpl = serviceImpl;
-        return this;
-    }
-
-    public String getMapper() {
-        return mapper;
-    }
-
-    public TemplateConfig setMapper(String mapper) {
-        this.mapper = mapper;
-        return this;
-    }
-
-    public String getXml() {
-        return xml;
-    }
-
-    public TemplateConfig setXml(String xml) {
-        this.xml = xml;
-        return this;
-    }
-
-    public String getController() {
-        return controller;
-    }
-
-    public TemplateConfig setController(String controller) {
-        this.controller = controller;
-        return this;
-    }
-
-}

+ 0 - 650
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java

@@ -1,650 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.builder;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.baomidou.mybatisplus.generator.config.ConstVal;
-import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
-import com.baomidou.mybatisplus.generator.config.GlobalConfig;
-import com.baomidou.mybatisplus.generator.config.PackageConfig;
-import com.baomidou.mybatisplus.generator.config.StrategyConfig;
-import com.baomidou.mybatisplus.generator.config.TemplateConfig;
-import com.baomidou.mybatisplus.generator.config.po.TableField;
-import com.baomidou.mybatisplus.generator.config.po.TableFill;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DbType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.config.rules.QuerySQL;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * <p>
- * 配置汇总 传递给文件生成工具
- * </p>
- *
- * @author YangHu, tangguo, hubin
- * @since 2016-08-30
- */
-public class ConfigBuilder {
-
-    /**
-     * 模板路径配置信息
-     */
-    private final TemplateConfig template;
-    /**
-     * 数据库配置
-     */
-    private final DataSourceConfig dataSourceConfig;
-    /**
-     * SQL连接
-     */
-    private Connection connection;
-    /**
-     * SQL语句类型
-     */
-    private QuerySQL querySQL;
-    private String superEntityClass;
-    private String superMapperClass;
-    /**
-     * service超类定义
-     */
-    private String superServiceClass;
-    private String superServiceImplClass;
-    private String superControllerClass;
-    /**
-     * 数据库表信息
-     */
-    private List<TableInfo> tableInfoList;
-    /**
-     * 包配置详情
-     */
-    private Map<String, String> packageInfo;
-    /**
-     * 路径配置信息
-     */
-    private Map<String, String> pathInfo;
-    /**
-     * 策略配置
-     */
-    private StrategyConfig strategyConfig;
-
-    /**
-     * 全局配置信息
-     */
-    private GlobalConfig globalConfig;
-
-    /**
-     * <p>
-     * 在构造器中处理配置
-     * </p>
-     *
-     * @param packageConfig    包配置
-     * @param dataSourceConfig 数据源配置
-     * @param strategyConfig   表配置
-     * @param template         模板配置
-     * @param globalConfig     全局配置
-     */
-    public ConfigBuilder(PackageConfig packageConfig, DataSourceConfig dataSourceConfig, StrategyConfig strategyConfig,
-                         TemplateConfig template, GlobalConfig globalConfig) {
-        // 全局配置
-        if (null == globalConfig) {
-            this.globalConfig = new GlobalConfig();
-        } else {
-            this.globalConfig = globalConfig;
-        }
-        // 模板配置
-        if (null == template) {
-            this.template = new TemplateConfig();
-        } else {
-            this.template = template;
-        }
-        // 包配置
-        if (null == packageConfig) {
-            handlerPackage(this.template, this.globalConfig.getOutputDir(), new PackageConfig());
-        } else {
-            handlerPackage(this.template, this.globalConfig.getOutputDir(), packageConfig);
-        }
-        this.dataSourceConfig = dataSourceConfig;
-        handlerDataSource(dataSourceConfig);
-        // 策略配置
-        if (null == strategyConfig) {
-            this.strategyConfig = new StrategyConfig();
-        } else {
-            this.strategyConfig = strategyConfig;
-        }
-        handlerStrategy(this.strategyConfig);
-    }
-
-    // ************************ 曝露方法 BEGIN*****************************
-
-    /**
-     * <p>
-     * 所有包配置信息
-     * </p>
-     *
-     * @return 包配置
-     */
-    public Map<String, String> getPackageInfo() {
-        return packageInfo;
-    }
-
-    /**
-     * <p>
-     * 所有路径配置
-     * </p>
-     *
-     * @return 路径配置
-     */
-    public Map<String, String> getPathInfo() {
-        return pathInfo;
-    }
-
-    public String getSuperEntityClass() {
-        return superEntityClass;
-    }
-
-    public String getSuperMapperClass() {
-        return superMapperClass;
-    }
-
-    /**
-     * <p>
-     * 获取超类定义
-     * </p>
-     *
-     * @return 完整超类名称
-     */
-    public String getSuperServiceClass() {
-        return superServiceClass;
-    }
-
-    public String getSuperServiceImplClass() {
-        return superServiceImplClass;
-    }
-
-    public String getSuperControllerClass() {
-        return superControllerClass;
-    }
-
-    /**
-     * <p>
-     * 表信息
-     * </p>
-     *
-     * @return 所有表信息
-     */
-    public List<TableInfo> getTableInfoList() {
-        return tableInfoList;
-    }
-
-    /**
-     * <p>
-     * 模板路径配置信息
-     * </p>
-     *
-     * @return 所以模板路径配置信息
-     */
-    public TemplateConfig getTemplate() {
-        return template == null ? new TemplateConfig() : template;
-    }
-
-    // ****************************** 曝露方法 END**********************************
-
-    /**
-     * <p>
-     * 处理包配置
-     * </p>
-     *
-     * @param template  TemplateConfig
-     * @param outputDir
-     * @param config    PackageConfig
-     */
-    private void handlerPackage(TemplateConfig template, String outputDir, PackageConfig config) {
-        packageInfo = new HashMap<>();
-        packageInfo.put(ConstVal.MODULENAME, config.getModuleName());
-        packageInfo.put(ConstVal.ENTITY, joinPackage(config.getParent(), config.getEntity()));
-        packageInfo.put(ConstVal.MAPPER, joinPackage(config.getParent(), config.getMapper()));
-        packageInfo.put(ConstVal.XML, joinPackage(config.getParent(), config.getXml()));
-        packageInfo.put(ConstVal.SERIVCE, joinPackage(config.getParent(), config.getService()));
-        packageInfo.put(ConstVal.SERVICEIMPL, joinPackage(config.getParent(), config.getServiceImpl()));
-        packageInfo.put(ConstVal.CONTROLLER, joinPackage(config.getParent(), config.getController()));
-
-        // 生成路径信息
-        pathInfo = new HashMap<>();
-        if (StringUtils.isNotEmpty(template.getEntity(getGlobalConfig().isKotlin()))) {
-            pathInfo.put(ConstVal.ENTITY_PATH, joinPath(outputDir, packageInfo.get(ConstVal.ENTITY)));
-        }
-        if (StringUtils.isNotEmpty(template.getMapper())) {
-            pathInfo.put(ConstVal.MAPPER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.MAPPER)));
-        }
-        if (StringUtils.isNotEmpty(template.getXml())) {
-            pathInfo.put(ConstVal.XML_PATH, joinPath(outputDir, packageInfo.get(ConstVal.XML)));
-        }
-        if (StringUtils.isNotEmpty(template.getService())) {
-            pathInfo.put(ConstVal.SERIVCE_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERIVCE)));
-        }
-        if (StringUtils.isNotEmpty(template.getServiceImpl())) {
-            pathInfo.put(ConstVal.SERVICEIMPL_PATH, joinPath(outputDir, packageInfo.get(ConstVal.SERVICEIMPL)));
-        }
-        if (StringUtils.isNotEmpty(template.getController())) {
-            pathInfo.put(ConstVal.CONTROLLER_PATH, joinPath(outputDir, packageInfo.get(ConstVal.CONTROLLER)));
-        }
-    }
-
-    /**
-     * <p>
-     * 处理数据源配置
-     * </p>
-     *
-     * @param config DataSourceConfig
-     */
-    private void handlerDataSource(DataSourceConfig config) {
-        connection = config.getConn();
-        querySQL = getQuerySQL(config.getDbType());
-    }
-
-    /**
-     * <p>
-     * 处理数据库表 加载数据库表、列、注释相关数据集
-     * </p>
-     *
-     * @param config StrategyConfig
-     */
-    private void handlerStrategy(StrategyConfig config) {
-        processTypes(config);
-        tableInfoList = getTablesInfo(config);
-    }
-
-    /**
-     * <p>
-     * 处理superClassName,IdClassType,IdStrategy配置
-     * </p>
-     *
-     * @param config 策略配置
-     */
-    private void processTypes(StrategyConfig config) {
-        if (StringUtils.isEmpty(config.getSuperServiceClass())) {
-            superServiceClass = ConstVal.SUPERD_SERVICE_CLASS;
-        } else {
-            superServiceClass = config.getSuperServiceClass();
-        }
-        if (StringUtils.isEmpty(config.getSuperServiceImplClass())) {
-            superServiceImplClass = ConstVal.SUPERD_SERVICEIMPL_CLASS;
-        } else {
-            superServiceImplClass = config.getSuperServiceImplClass();
-        }
-        if (StringUtils.isEmpty(config.getSuperMapperClass())) {
-            superMapperClass = ConstVal.SUPERD_MAPPER_CLASS;
-        } else {
-            superMapperClass = config.getSuperMapperClass();
-        }
-        superEntityClass = config.getSuperEntityClass();
-        superControllerClass = config.getSuperControllerClass();
-    }
-
-    /**
-     * <p>
-     * 处理表对应的类名称
-     * </P>
-     *
-     * @param tableList   表名称
-     * @param strategy    命名策略
-     * @param tablePrefix
-     * @return 补充完整信息后的表
-     */
-    private List<TableInfo> processTable(List<TableInfo> tableList, NamingStrategy strategy, String[] tablePrefix) {
-        for (TableInfo tableInfo : tableList) {
-            tableInfo.setEntityName(strategyConfig, NamingStrategy.capitalFirst(processName(tableInfo.getName(), strategy, tablePrefix)));
-            if (StringUtils.isNotEmpty(globalConfig.getMapperName())) {
-                tableInfo.setMapperName(String.format(globalConfig.getMapperName(), tableInfo.getEntityName()));
-            } else {
-                tableInfo.setMapperName(tableInfo.getEntityName() + ConstVal.MAPPER);
-            }
-            if (StringUtils.isNotEmpty(globalConfig.getXmlName())) {
-                tableInfo.setXmlName(String.format(globalConfig.getXmlName(), tableInfo.getEntityName()));
-            } else {
-                tableInfo.setXmlName(tableInfo.getEntityName() + ConstVal.MAPPER);
-            }
-            if (StringUtils.isNotEmpty(globalConfig.getServiceName())) {
-                tableInfo.setServiceName(String.format(globalConfig.getServiceName(), tableInfo.getEntityName()));
-            } else {
-                tableInfo.setServiceName("I" + tableInfo.getEntityName() + ConstVal.SERIVCE);
-            }
-            if (StringUtils.isNotEmpty(globalConfig.getServiceImplName())) {
-                tableInfo.setServiceImplName(String.format(globalConfig.getServiceImplName(), tableInfo.getEntityName()));
-            } else {
-                tableInfo.setServiceImplName(tableInfo.getEntityName() + ConstVal.SERVICEIMPL);
-            }
-            if (StringUtils.isNotEmpty(globalConfig.getControllerName())) {
-                tableInfo.setControllerName(String.format(globalConfig.getControllerName(), tableInfo.getEntityName()));
-            } else {
-                tableInfo.setControllerName(tableInfo.getEntityName() + ConstVal.CONTROLLER);
-            }
-        }
-        return tableList;
-    }
-
-    /**
-     * <p>
-     * 获取所有的数据库表信息
-     * </p>
-     */
-    private List<TableInfo> getTablesInfo(StrategyConfig config) {
-        boolean isInclude = (null != config.getInclude() && config.getInclude().length > 0);
-        boolean isExclude = (null != config.getExclude() && config.getExclude().length > 0);
-        if (isInclude && isExclude) {
-            throw new RuntimeException("<strategy> 标签中 <include> 与 <exclude> 只能配置一项!");
-        }
-        //所有的表信息
-        List<TableInfo> tableList = new ArrayList<>();
-
-        //需要反向生成或排除的表信息
-        List<TableInfo> includeTableList = new ArrayList<>();
-        List<TableInfo> excludeTableList = new ArrayList<>();
-
-        //不存在的表名
-        Set<String> notExistTables = new HashSet<>();
-
-        NamingStrategy strategy = config.getNaming();
-        PreparedStatement preparedStatement = null;
-        try {
-            String tableCommentsSql = querySQL.getTableCommentsSql();
-            if (QuerySQL.POSTGRE_SQL == querySQL) {
-                tableCommentsSql = String.format(tableCommentsSql, dataSourceConfig.getSchemaname());
-            }
-            preparedStatement = connection.prepareStatement(tableCommentsSql);
-            ResultSet results = preparedStatement.executeQuery();
-            TableInfo tableInfo;
-            while (results.next()) {
-                String tableName = results.getString(querySQL.getTableName());
-                if (StringUtils.isNotEmpty(tableName)) {
-                    String tableComment = results.getString(querySQL.getTableComment());
-                    tableInfo = new TableInfo();
-                    tableInfo.setName(tableName);
-                    tableInfo.setComment(tableComment);
-                    if (isInclude) {
-                        for (String includeTab : config.getInclude()) {
-                            if (includeTab.equalsIgnoreCase(tableName)) {
-                                includeTableList.add(tableInfo);
-                            } else {
-                                notExistTables.add(includeTab);
-                            }
-                        }
-                    } else if (isExclude) {
-                        for (String excludeTab : config.getExclude()) {
-                            if (excludeTab.equalsIgnoreCase(tableName)) {
-                                excludeTableList.add(tableInfo);
-                            } else {
-                                notExistTables.add(excludeTab);
-                            }
-                        }
-                    }
-                    tableList.add(this.convertTableFields(tableInfo, strategy));
-                } else {
-                    System.err.println("当前数据库为空!!!");
-                }
-            }
-            // 将已经存在的表移除,获取配置中数据库不存在的表
-            for (TableInfo tabInfo : tableList) {
-                notExistTables.remove(tabInfo.getName());
-            }
-
-            if (notExistTables.size() > 0) {
-                System.err.println("表 " + notExistTables + " 在数据库中不存在!!!");
-            }
-
-            // 需要反向生成的表信息
-            if (isExclude) {
-                tableList.removeAll(excludeTableList);
-                includeTableList = tableList;
-            }
-            if (!isInclude && !isExclude) {
-                includeTableList = tableList;
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            // 释放资源
-            try {
-                if (preparedStatement != null) {
-                    preparedStatement.close();
-                }
-                if (connection != null) {
-                    connection.close();
-                }
-            } catch (SQLException e) {
-                e.printStackTrace();
-            }
-        }
-        return processTable(includeTableList, strategy, config.getTablePrefix());
-    }
-
-
-    /**
-     * <p>
-     * 判断主键是否为identity,目前仅对mysql进行检查
-     * </p>
-     *
-     * @param results ResultSet
-     * @return 主键是否为identity
-     * @throws SQLException
-     */
-    private boolean isKeyIdentity(ResultSet results) throws SQLException {
-        if (QuerySQL.MYSQL == this.querySQL) {
-            String extra = results.getString("Extra");
-            if ("auto_increment".equals(extra)) {
-                return true;
-            }
-        } else if (QuerySQL.SQL_SERVER == this.querySQL) {
-            int isIdentity = results.getInt("isIdentity");
-            return 1 == isIdentity;
-        }
-        return false;
-    }
-
-    /**
-     * <p>
-     * 将字段信息与表信息关联
-     * </p>
-     *
-     * @param tableInfo 表信息
-     * @param strategy  命名策略
-     * @return
-     */
-    private TableInfo convertTableFields(TableInfo tableInfo, NamingStrategy strategy) {
-        boolean haveId = false;
-        List<TableField> fieldList = new ArrayList<>();
-        List<TableField> commonFieldList = new ArrayList<>();
-        try {
-            String tableFieldsSql = querySQL.getTableFieldsSql();
-            if (QuerySQL.POSTGRE_SQL == querySQL) {
-                tableFieldsSql = String.format(tableFieldsSql, dataSourceConfig.getSchemaname(), tableInfo.getName());
-            } else {
-                tableFieldsSql = String.format(tableFieldsSql, tableInfo.getName());
-            }
-            PreparedStatement preparedStatement = connection.prepareStatement(tableFieldsSql);
-            ResultSet results = preparedStatement.executeQuery();
-            while (results.next()) {
-                TableField field = new TableField();
-                String key = results.getString(querySQL.getFieldKey());
-                // 避免多重主键设置,目前只取第一个找到ID,并放到list中的索引为0的位置
-                boolean isId = StringUtils.isNotEmpty(key) && key.toUpperCase().equals("PRI");
-                // 处理ID
-                if (isId && !haveId) {
-                    field.setKeyFlag(true);
-                    if (isKeyIdentity(results)) {
-                        field.setKeyIdentityFlag(true);
-                    }
-                    haveId = true;
-                } else {
-                    field.setKeyFlag(false);
-                }
-                // 处理其它信息
-                field.setName(results.getString(querySQL.getFieldName()));
-                field.setType(results.getString(querySQL.getFieldType()));
-                field.setPropertyName(strategyConfig, processName(field.getName(), strategy));
-                field.setColumnType(dataSourceConfig.getTypeConvert().processTypeConvert(field.getType()));
-                field.setComment(results.getString(querySQL.getFieldComment()));
-                if (strategyConfig.includeSuperEntityColumns(field.getName())) {
-                    // 跳过公共字段
-                    commonFieldList.add(field);
-                    continue;
-                }
-                // 填充逻辑判断
-                List<TableFill> tableFillList = this.getStrategyConfig().getTableFillList();
-                if (null != tableFillList) {
-                    for (TableFill tableFill : tableFillList) {
-                        if (tableFill.getFieldName().equals(field.getName())) {
-                            field.setFill(tableFill.getFieldFill().name());
-                            break;
-                        }
-                    }
-                }
-                fieldList.add(field);
-            }
-        } catch (SQLException e) {
-            System.err.println("SQL Exception:" + e.getMessage());
-        }
-        tableInfo.setFields(fieldList);
-        tableInfo.setCommonFields(commonFieldList);
-        return tableInfo;
-    }
-
-    /**
-     * <p>
-     * 连接路径字符串
-     * </p>
-     *
-     * @param parentDir   路径常量字符串
-     * @param packageName 包名
-     * @return 连接后的路径
-     */
-    private String joinPath(String parentDir, String packageName) {
-        if (StringUtils.isEmpty(parentDir)) {
-            parentDir = System.getProperty(ConstVal.JAVA_TMPDIR);
-        }
-        if (!StringUtils.endsWith(parentDir, File.separator)) {
-            parentDir += File.separator;
-        }
-        packageName = packageName.replaceAll("\\.", "\\" + File.separator);
-        return parentDir + packageName;
-    }
-
-    /**
-     * <p>
-     * 连接父子包名
-     * </p>
-     *
-     * @param parent     父包名
-     * @param subPackage 子包名
-     * @return 连接后的包名
-     */
-    private String joinPackage(String parent, String subPackage) {
-        if (StringUtils.isEmpty(parent)) {
-            return subPackage;
-        }
-        return parent + "." + subPackage;
-    }
-
-    /**
-     * <p>
-     * 处理字段名称
-     * </p>
-     *
-     * @return 根据策略返回处理后的名称
-     */
-    private String processName(String name, NamingStrategy strategy) {
-        return processName(name, strategy, null);
-    }
-
-    /**
-     * <p>
-     * 处理字段名称
-     * </p>
-     *
-     * @param name
-     * @param strategy
-     * @param tablePrefix
-     * @return 根据策略返回处理后的名称
-     */
-    private String processName(String name, NamingStrategy strategy, String[] tablePrefix) {
-        boolean removePrefix = false;
-        if (tablePrefix != null && tablePrefix.length >= 1) {
-            removePrefix = true;
-        }
-        String propertyName;
-        if (removePrefix) {
-            if (strategy == NamingStrategy.underline_to_camel) {
-                // 删除前缀、下划线转驼峰
-                propertyName = NamingStrategy.removePrefixAndCamel(name, tablePrefix);
-            } else {
-                // 删除前缀
-                propertyName = NamingStrategy.removePrefix(name, tablePrefix);
-            }
-        } else if (strategy == NamingStrategy.underline_to_camel) {
-            // 下划线转驼峰
-            propertyName = NamingStrategy.underlineToCamel(name);
-        } else {
-            // 不处理
-            propertyName = name;
-        }
-        return propertyName;
-    }
-
-    /**
-     * 获取当前的SQL类型
-     *
-     * @return DB类型
-     */
-    private QuerySQL getQuerySQL(DbType dbType) {
-        for (QuerySQL qs : QuerySQL.values()) {
-            if (qs.getDbType().equals(dbType.getValue())) {
-                return qs;
-            }
-        }
-        return QuerySQL.MYSQL;
-    }
-
-    public StrategyConfig getStrategyConfig() {
-        return strategyConfig;
-    }
-
-    public ConfigBuilder setStrategyConfig(StrategyConfig strategyConfig) {
-        this.strategyConfig = strategyConfig;
-        return this;
-    }
-
-    public GlobalConfig getGlobalConfig() {
-        return globalConfig;
-    }
-
-    public ConfigBuilder setGlobalConfig(GlobalConfig globalConfig) {
-        this.globalConfig = globalConfig;
-        return this;
-    }
-
-}

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/builder/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 代码生成器,构建类
- */
-package com.baomidou.mybatisplus.generator.config.builder;

+ 0 - 64
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/MySqlTypeConvert.java

@@ -1,64 +0,0 @@
-/**
- * Copyright (c) 2011-2016, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.converts;
-
-import com.baomidou.mybatisplus.generator.config.ITypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
-
-/**
- * <p>
- * MYSQL 数据库字段类型转换
- * </p>
- *
- * @author hubin
- * @date 2017-01-20
- */
-public class MySqlTypeConvert implements ITypeConvert {
-
-    @Override
-    public DbColumnType processTypeConvert(String fieldType) {
-        String t = fieldType.toLowerCase();
-        if (t.contains("char") || t.contains("text")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bigint")) {
-            return DbColumnType.LONG;
-        } else if (t.contains("int")) {
-            return DbColumnType.INTEGER;
-        } else if (t.contains("date") || t.contains("time") || t.contains("year")) {
-            return DbColumnType.DATE;
-        } else if (t.contains("text")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bit")) {
-            return DbColumnType.BOOLEAN;
-        } else if (t.contains("decimal")) {
-            return DbColumnType.BIG_DECIMAL;
-        } else if (t.contains("clob")) {
-            return DbColumnType.CLOB;
-        } else if (t.contains("blob")) {
-            return DbColumnType.BLOB;
-        } else if (t.contains("binary")) {
-            return DbColumnType.BYTE_ARRAY;
-        } else if (t.contains("float")) {
-            return DbColumnType.FLOAT;
-        } else if (t.contains("double")) {
-            return DbColumnType.DOUBLE;
-        } else if (t.contains("json") || t.contains("enum")) {
-            return DbColumnType.STRING;
-        }
-        return DbColumnType.STRING;
-    }
-
-}

+ 0 - 59
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/OracleTypeConvert.java

@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2011-2016, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.converts;
-
-import com.baomidou.mybatisplus.generator.config.ITypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
-
-/**
- * <p>
- * ORACLE 字段类型转换
- * </p>
- *
- * @author hubin
- * @date 2017-01-20
- */
-public class OracleTypeConvert implements ITypeConvert {
-
-    @Override
-    public DbColumnType processTypeConvert(String fieldType) {
-        String t = fieldType.toUpperCase();
-        if (t.contains("CHAR")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("DATE") || t.contains("TIMESTAMP")) {
-            return DbColumnType.DATE;
-        } else if (t.contains("NUMBER")) {
-            if (t.matches("NUMBER\\(+\\d\\)")) {
-                return DbColumnType.INTEGER;
-            } else if (t.matches("NUMBER\\(+\\d{2}+\\)")) {
-                return DbColumnType.LONG;
-            }
-            return DbColumnType.DOUBLE;
-        } else if (t.contains("FLOAT")) {
-            return DbColumnType.FLOAT;
-        } else if (t.contains("clob")) {
-            return DbColumnType.CLOB;
-        } else if (t.contains("BLOB")) {
-            return DbColumnType.OBJECT;
-        } else if (t.contains("binary")) {
-            return DbColumnType.BYTE_ARRAY;
-        } else if (t.contains("RAW")) {
-            return DbColumnType.BYTE_ARRAY;
-        }
-        return DbColumnType.STRING;
-    }
-
-}

+ 0 - 64
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/PostgreSqlTypeConvert.java

@@ -1,64 +0,0 @@
-/**
- * Copyright (c) 2011-2016, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.converts;
-
-import com.baomidou.mybatisplus.generator.config.ITypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
-
-/**
- * <p>
- * PostgreSQL 字段类型转换
- * </p>
- *
- * @author hubin
- * @date 2017-01-20
- */
-public class PostgreSqlTypeConvert implements ITypeConvert {
-
-    @Override
-    public DbColumnType processTypeConvert(String fieldType) {
-        String t = fieldType.toLowerCase();
-        if (t.contains("char") || t.contains("text")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bigint")) {
-            return DbColumnType.LONG;
-        } else if (t.contains("int")) {
-            return DbColumnType.INTEGER;
-        } else if (t.contains("date") || t.contains("time") || t.contains("year")) {
-            return DbColumnType.DATE;
-        } else if (t.contains("text")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bit")) {
-            return DbColumnType.BOOLEAN;
-        } else if (t.contains("decimal")) {
-            return DbColumnType.BIG_DECIMAL;
-        } else if (t.contains("clob")) {
-            return DbColumnType.CLOB;
-        } else if (t.contains("blob")) {
-            return DbColumnType.BYTE_ARRAY;
-        } else if (t.contains("float")) {
-            return DbColumnType.FLOAT;
-        } else if (t.contains("double")) {
-            return DbColumnType.DOUBLE;
-        } else if (t.contains("json") || t.contains("enum")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("boolean")) {
-            return DbColumnType.BOOLEAN;
-        }
-        return DbColumnType.STRING;
-    }
-
-}

+ 0 - 58
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/converts/SqlServerTypeConvert.java

@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2011-2016, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.converts;
-
-import com.baomidou.mybatisplus.generator.config.ITypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
-
-/**
- * <p>
- * SQLServer 字段类型转换
- * </p>
- *
- * @author hubin
- * @date 2017-01-20
- */
-public class SqlServerTypeConvert implements ITypeConvert {
-
-    @Override
-    public DbColumnType processTypeConvert(String fieldType) {
-        String t = fieldType.toLowerCase();
-        if (t.contains("char") || t.contains("text") || t.contains("xml")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bigint")) {
-            return DbColumnType.LONG;
-        } else if (t.contains("int")) {
-            return DbColumnType.INTEGER;
-        } else if (t.contains("date") || t.contains("time")) {
-            return DbColumnType.DATE;
-        } else if (t.contains("text")) {
-            return DbColumnType.STRING;
-        } else if (t.contains("bit")) {
-            return DbColumnType.BOOLEAN;
-        } else if (t.contains("decimal") || t.contains("numeric")) {
-            return DbColumnType.DOUBLE;
-        } else if (t.contains("money")) {
-            return DbColumnType.BIG_DECIMAL;
-        } else if (t.contains("binary") || t.contains("image")) {
-            return DbColumnType.BYTE_ARRAY;
-        } else if (t.contains("float") || t.contains("real")) {
-            return DbColumnType.FLOAT;
-        }
-        return DbColumnType.STRING;
-    }
-
-}

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 代码生成器,配置相关类
- */
-package com.baomidou.mybatisplus.generator.config;

+ 0 - 160
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java

@@ -1,160 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.po;
-
-import com.baomidou.mybatisplus.generator.config.StrategyConfig;
-import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * <p>
- * 表字段信息
- * </p>
- *
- * @author YangHu
- * @since 2016-12-03
- */
-public class TableField {
-
-    private boolean convert;
-    private boolean keyFlag;
-    /**
-     * 主键是否为自增类型
-     */
-    private boolean keyIdentityFlag;
-    private String name;
-    private String type;
-    private String propertyName;
-    private DbColumnType columnType;
-    private String comment;
-    private String fill;
-
-    public boolean isConvert() {
-        return convert;
-    }
-
-    protected void setConvert(StrategyConfig strategyConfig) {
-        if (strategyConfig.isCapitalModeNaming(name)) {
-            this.convert = false;
-        } else {
-            // 转换字段
-            if (StrategyConfig.DB_COLUMN_UNDERLINE) {
-                // 包含大写处理
-                if (StringUtils.containsUpperCase(name)) {
-                    this.convert = true;
-                }
-            } else if (!name.equals(propertyName)) {
-                this.convert = true;
-            }
-        }
-    }
-
-    public void setConvert(boolean convert) {
-        this.convert = convert;
-    }
-
-    public boolean isKeyFlag() {
-        return keyFlag;
-    }
-
-    public void setKeyFlag(boolean keyFlag) {
-        this.keyFlag = keyFlag;
-    }
-
-    public boolean isKeyIdentityFlag() {
-        return keyIdentityFlag;
-    }
-
-    public void setKeyIdentityFlag(boolean keyIdentityFlag) {
-        this.keyIdentityFlag = keyIdentityFlag;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    public void setPropertyName(StrategyConfig strategyConfig, String propertyName) {
-        this.propertyName = propertyName;
-        this.setConvert(strategyConfig);
-    }
-
-    public DbColumnType getColumnType() {
-        return columnType;
-    }
-
-    public void setColumnType(DbColumnType columnType) {
-        this.columnType = columnType;
-    }
-
-    public String getPropertyType() {
-        if (null != columnType) {
-            return columnType.getType();
-        }
-        return null;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
-    }
-
-    /**
-     * 按JavaBean规则来生成get和set方法
-     */
-    public String getCapitalName() {
-        if (propertyName.length() <= 1) {
-            return propertyName.toUpperCase();
-        }
-        String setGetName = propertyName;
-        if (DbColumnType.BASE_BOOLEAN.getType().equalsIgnoreCase(columnType.getType())) {
-            setGetName = StringUtils.removeIsPrefixIfBoolean(setGetName, Boolean.class);
-        }
-        // 第一个字母 小写、 第二个字母 大写 ,特殊处理
-        String firstChar = setGetName.substring(0, 1);
-        if (Character.isLowerCase(firstChar.toCharArray()[0])
-                && Character.isUpperCase(setGetName.substring(1, 2).toCharArray()[0])) {
-            return firstChar.toLowerCase() + setGetName.substring(1);
-        }
-        return firstChar.toUpperCase() + setGetName.substring(1);
-    }
-
-    public String getFill() {
-        return fill;
-    }
-
-    public void setFill(String fill) {
-        this.fill = fill;
-    }
-}

+ 0 - 59
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableFill.java

@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.po;
-
-import com.baomidou.mybatisplus.enums.FieldFill;
-
-/**
- * <p>
- * 字段填充
- * </p>
- *
- * @author hubin
- * @since 2017-06-26
- */
-public class TableFill {
-
-    /* 字段名称 */
-    private String fieldName;
-    /* 忽略类型 */
-    private FieldFill fieldFill;
-
-    private TableFill() {
-        // to do nothing
-    }
-
-    public TableFill(String fieldName, FieldFill ignore) {
-        this.fieldName = fieldName;
-        this.fieldFill = ignore;
-    }
-
-    public String getFieldName() {
-        return fieldName;
-    }
-
-    public void setFieldName(String fieldName) {
-        this.fieldName = fieldName;
-    }
-
-    public FieldFill getFieldFill() {
-        return fieldFill;
-    }
-
-    public void setFieldFill(FieldFill fieldFill) {
-        this.fieldFill = fieldFill;
-    }
-}

+ 0 - 254
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java

@@ -1,254 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.po;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.baomidou.mybatisplus.generator.config.StrategyConfig;
-import com.baomidou.mybatisplus.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * <p>
- * 表信息,关联到当前字段信息
- * </p>
- *
- * @author YangHu
- * @since 2016/8/30
- */
-public class TableInfo {
-
-    private boolean convert;
-    private String name;
-    private String comment;
-
-    private String entityName;
-    private String mapperName;
-    private String xmlName;
-    private String serviceName;
-    private String serviceImplName;
-    private String controllerName;
-
-    private List<TableField> fields;
-    private List<TableField> commonFields;// 公共字段
-    private List<String> importPackages = new ArrayList<>();
-    private String fieldNames;
-
-    public boolean isConvert() {
-        return convert;
-    }
-
-    protected void setConvert(StrategyConfig strategyConfig) {
-        if (strategyConfig.containsTablePrefix(name)) {
-            // 包含前缀
-            this.convert = true;
-        } else if (strategyConfig.isCapitalModeNaming(name)) {
-            // 包含
-            this.convert = false;
-        } else {
-            // 转换字段
-            if (StrategyConfig.DB_COLUMN_UNDERLINE) {
-                // 包含大写处理
-                if (StringUtils.containsUpperCase(name)) {
-                    this.convert = true;
-                }
-            } else if (!entityName.equalsIgnoreCase(name)) {
-                this.convert = true;
-            }
-        }
-    }
-
-    public void setConvert(boolean convert) {
-        this.convert = convert;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
-    }
-
-    public String getEntityPath() {
-        StringBuilder ep = new StringBuilder();
-        ep.append(entityName.substring(0, 1).toLowerCase());
-        ep.append(entityName.substring(1));
-        return ep.toString();
-    }
-
-    public String getEntityName() {
-        return entityName;
-    }
-
-    public void setEntityName(StrategyConfig strategyConfig, String entityName) {
-        this.entityName = entityName;
-        this.setConvert(strategyConfig);
-    }
-
-    public String getMapperName() {
-        return mapperName;
-    }
-
-    public void setMapperName(String mapperName) {
-        this.mapperName = mapperName;
-    }
-
-    public String getXmlName() {
-        return xmlName;
-    }
-
-    public void setXmlName(String xmlName) {
-        this.xmlName = xmlName;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    public String getServiceImplName() {
-        return serviceImplName;
-    }
-
-    public void setServiceImplName(String serviceImplName) {
-        this.serviceImplName = serviceImplName;
-    }
-
-    public String getControllerName() {
-        return controllerName;
-    }
-
-    public void setControllerName(String controllerName) {
-        this.controllerName = controllerName;
-    }
-
-    public List<TableField> getFields() {
-        return fields;
-    }
-
-    public void setFields(List<TableField> fields) {
-        if (CollectionUtils.isNotEmpty(fields)) {
-            this.fields = fields;
-            // 收集导入包信息
-            Set<String> pkgSet = new HashSet<>();
-            for (TableField field : fields) {
-                if (null != field.getColumnType() && null != field.getColumnType().getPkg()) {
-                    pkgSet.add(field.getColumnType().getPkg());
-                }
-                if (field.isKeyFlag()) {
-                    // 主键
-                    if (field.isConvert() || field.isKeyIdentityFlag()) {
-                        pkgSet.add("com.baomidou.mybatisplus.annotations.TableId");
-                    }
-                    // 自增
-                    if (field.isKeyIdentityFlag()) {
-                        pkgSet.add("com.baomidou.mybatisplus.enums.IdType");
-                    }
-                } else if (field.isConvert()) {
-                    // 普通字段
-                    pkgSet.add("com.baomidou.mybatisplus.annotations.TableField");
-                }
-                if (null != field.getFill()) {
-                    // 填充字段
-                    pkgSet.add("com.baomidou.mybatisplus.annotations.TableField");
-                    pkgSet.add("com.baomidou.mybatisplus.enums.FieldFill");
-                }
-            }
-            if (!pkgSet.isEmpty()) {
-                this.importPackages = new ArrayList<>(Arrays.asList(pkgSet.toArray(new String[]{})));
-            }
-        }
-    }
-
-    public List<TableField> getCommonFields() {
-        return commonFields;
-    }
-
-    public void setCommonFields(List<TableField> commonFields) {
-        this.commonFields = commonFields;
-    }
-
-    public List<String> getImportPackages() {
-        return importPackages;
-    }
-
-    public void setImportPackages(String pkg) {
-        importPackages.add(pkg);
-    }
-
-    /**
-     * 逻辑删除
-     */
-    public boolean isLogicDelete(String logicDeletePropertyName) {
-        for (TableField tableField : fields) {
-            if (tableField.getName().equals(logicDeletePropertyName)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 转换filed实体为xmlmapper中的basecolumn字符串信息
-     *
-     * @return
-     */
-    public String getFieldNames() {
-        if (StringUtils.isEmpty(fieldNames)) {
-            StringBuilder names = new StringBuilder();
-            for (int i = 0; i < fields.size(); i++) {
-                TableField fd = fields.get(i);
-                if (i == fields.size() - 1) {
-                    names.append(cov2col(fd));
-                } else {
-                    names.append(cov2col(fd)).append(", ");
-                }
-            }
-            fieldNames = names.toString();
-        }
-        return fieldNames;
-    }
-
-    /**
-     * mapper xml中的字字段添加as
-     *
-     * @param field 字段实体
-     * @return 转换后的信息
-     */
-    private String cov2col(TableField field) {
-        if (null != field) {
-            return field.isConvert() ? field.getName() + " AS " + field.getPropertyName() : field.getName();
-        }
-        return StringUtils.EMPTY;
-    }
-
-}

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/po/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 代码生成器,输出相关类
- */
-package com.baomidou.mybatisplus.generator.config.po;

+ 0 - 77
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/DbColumnType.java

@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.rules;
-
-/**
- * <p>
- * 表字段类型
- * </p>
- *
- * @author hubin
- * @since 2017-01-11
- */
-public enum DbColumnType {
-    // 基本类型
-    BASE_INT("int", null),
-    BASE_BOOLEAN("boolean", null),
-    BASE_FLOAT("float", null),
-    BASE_DOUBLE("double", null),
-
-    // 包装类型
-    STRING("String", null),
-    LONG("Long", null),
-    INTEGER("Integer", null),
-    FLOAT("Float", null),
-    DOUBLE("Double", null),
-    BOOLEAN("Boolean", null),
-    BYTE_ARRAY("byte[]", null),
-    CHARACTER("Character", null),
-    OBJECT("Object", null),
-    DATE("Date", "java.util.Date"),
-    TIME("Time", "java.sql.Time"),
-    BLOB("Blob", "java.sql.Blob"),
-    CLOB("Clob", "java.sql.Clob"),
-    TIMESTAMP("Timestamp", "java.sql.Timestamp"),
-    BIG_INTEGER("BigInteger", "java.math.BigInteger"),
-    BIG_DECIMAL("BigDecimal", "java.math.BigDecimal"),
-    LOCAL_DATE("LocalDate", "java.time.LocalDate"),
-    LOCAL_TIME("LocalTime", "java.time.LocalTime"),
-    LOCAL_DATE_TIME("LocalDateTime", "java.time.LocalDateTime");
-
-    /**
-     * 类型
-     */
-    private final String type;
-
-    /**
-     * 包路径
-     */
-    private final String pkg;
-
-    DbColumnType(final String type, final String pkg) {
-        this.type = type;
-        this.pkg = pkg;
-    }
-
-    public String getType() {
-        return this.type;
-    }
-
-    public String getPkg() {
-        return this.pkg;
-    }
-
-}

+ 0 - 38
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/DbType.java

@@ -1,38 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.rules;
-
-/**
- * 数据库类型定义
- *
- * @author YangHu
- * @since 2016/8/30
- */
-public enum DbType {
-
-    MYSQL("mysql"), ORACLE("oracle"), SQL_SERVER("sql_server"), POSTGRE_SQL("postgre_sql");
-
-    private final String value;
-
-    DbType(String value) {
-        this.value = value;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-}

+ 0 - 132
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/NamingStrategy.java

@@ -1,132 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.rules;
-
-import com.baomidou.mybatisplus.generator.config.ConstVal;
-import com.baomidou.mybatisplus.toolkit.StringUtils;
-
-/**
- * 从数据库表到文件的命名策略
- *
- * @author YangHu, tangguo
- * @since 2016/8/30
- */
-public enum NamingStrategy {
-    /**
-     * 不做任何改变,原样输出
-     */
-    nochange,
-    /**
-     * 下划线转驼峰命名
-     */
-    underline_to_camel;
-
-    public static String underlineToCamel(String name) {
-        // 快速检查
-        if (StringUtils.isEmpty(name)) {
-            // 没必要转换
-            return "";
-        }
-        String tempName = name;
-        StringBuilder result = new StringBuilder();
-        // 大写数字下划线组成转为小写
-        if (StringUtils.isCapitalMode(name)) {
-            tempName = name.toLowerCase();
-        }
-        // 用下划线将原始字符串分割
-        String camels[] = tempName.split(ConstVal.UNDERLINE);
-        for (String camel : camels) {
-            // 跳过原始字符串中开头、结尾的下换线或双重下划线
-            if (StringUtils.isEmpty(camel)) {
-                continue;
-            }
-            // 处理真正的驼峰片段
-            if (result.length() == 0) {
-                // 第一个驼峰片段,全部字母都小写
-                result.append(camel);
-            } else {
-                // 其他的驼峰片段,首字母大写
-                result.append(capitalFirst(camel));
-            }
-        }
-        return result.toString();
-    }
-
-    /**
-     * 去掉下划线前缀
-     *
-     * @param name
-     * @return
-     */
-    public static String removePrefix(String name) {
-        if (StringUtils.isEmpty(name)) {
-            return "";
-        }
-        int idx = name.indexOf(ConstVal.UNDERLINE);
-        if (idx == -1) {
-            return name;
-        }
-        return name.substring(idx + 1);
-    }
-
-    /**
-     * 去掉指定的前缀
-     *
-     * @param name
-     * @param prefix
-     * @return
-     */
-    public static String removePrefix(String name, String[] prefix) {
-        if (StringUtils.isEmpty(name)) {
-            return "";
-        }
-        if (null != prefix) {
-            for (String pf : prefix) {
-                if (name.toLowerCase().matches("^" + pf.toLowerCase() + ".*")) {
-                    // 判断是否有匹配的前缀,然后截取前缀
-                    // 删除前缀
-                    return name.substring(pf.length());
-                }
-            }
-        }
-        return name;
-    }
-
-    /**
-     * 去掉下划线前缀且将后半部分转成驼峰格式
-     *
-     * @param name
-     * @param tablePrefix
-     * @return
-     */
-    public static String removePrefixAndCamel(String name, String[] tablePrefix) {
-        return underlineToCamel(removePrefix(name, tablePrefix));
-    }
-
-    /**
-     * 实体首字母大写
-     *
-     * @param name 待转换的字符串
-     * @return 转换后的字符串
-     */
-    public static String capitalFirst(String name) {
-        if (StringUtils.isNotEmpty(name)) {
-            return name.substring(0, 1).toUpperCase() + name.substring(1);
-        }
-        return "";
-    }
-
-}

+ 0 - 135
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/QuerySQL.java

@@ -1,135 +0,0 @@
-/**
- * Copyright (c) 2011-2020, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.generator.config.rules;
-
-/**
- * <p>
- * 表数据查询
- * </p>
- *
- * @author hubin, tangguo
- * @since 2016-04-25
- */
-public enum QuerySQL {
-    MYSQL("mysql", "show tables", "show table status", "show full fields from `%s`", "NAME", "COMMENT", "FIELD", "TYPE",
-            "COMMENT", "KEY"),
-
-    ORACLE("oracle", "SELECT * FROM USER_TABLES", "SELECT * FROM USER_TAB_COMMENTS",
-            "SELECT A.COLUMN_NAME, CASE WHEN A.DATA_TYPE='NUMBER' THEN "
-                    + "(CASE WHEN A.DATA_PRECISION IS NULL THEN A.DATA_TYPE "
-                    + "WHEN NVL(A.DATA_SCALE, 0) > 0 THEN A.DATA_TYPE||'('||A.DATA_PRECISION||','||A.DATA_SCALE||')' "
-                    + "ELSE A.DATA_TYPE||'('||A.DATA_PRECISION||')' END) "
-                    + "ELSE A.DATA_TYPE END DATA_TYPE, B.COMMENTS,DECODE(C.POSITION, '1', 'PRI') KEY "
-                    + "FROM USER_TAB_COLUMNS A INNER JOIN USER_COL_COMMENTS B ON A.TABLE_NAME = B.TABLE_NAME"
-                    + " AND A.COLUMN_NAME = B.COLUMN_NAME LEFT JOIN USER_CONSTRAINTS D "
-                    + "ON D.TABLE_NAME = A.TABLE_NAME AND D.CONSTRAINT_TYPE = 'P' "
-                    + "LEFT JOIN USER_CONS_COLUMNS C ON C.CONSTRAINT_NAME = D.CONSTRAINT_NAME "
-                    + "AND C.COLUMN_NAME=A.COLUMN_NAME WHERE A.TABLE_NAME = '%s' ORDER BY A.COLUMN_ID ",
-            "TABLE_NAME", "COMMENTS", "COLUMN_NAME", "DATA_TYPE", "COMMENTS", "KEY"),
-
-    SQL_SERVER("sql_server",
-            "select cast(name as varchar(500)) as TABLE_NAME from sysObjects where xtype='U' order by name",
-            "select name as TABLE_NAME,(select cast(value as varchar(500)) from sys.extended_properties where major_id=id and minor_id = 0) as COMMENTS from sysobjects where xtype='U'",
-            "SELECT  cast(a.NAME AS VARCHAR(500)) AS TABLE_NAME,cast(b.NAME AS VARCHAR(500)) AS COLUMN_NAME, "
-                    + "cast(c.VALUE AS VARCHAR(500)) AS COMMENTS,cast(sys.types.NAME AS VARCHAR (500)) AS DATA_TYPE,"
-                    + "(" + " SELECT CASE count(1) WHEN 1 then 'PRI' ELSE '' END"
-                    + " FROM syscolumns,sysobjects,sysindexes,sysindexkeys,systypes "
-                    + " WHERE syscolumns.xusertype = systypes.xusertype AND syscolumns.id = object_id (A.NAME) AND sysobjects.xtype = 'PK'"
-                    + " AND sysobjects.parent_obj = syscolumns.id " + " AND sysindexes.id = syscolumns.id "
-                    + " AND sysobjects.NAME = sysindexes.NAME AND sysindexkeys.id = syscolumns.id "
-                    + " AND sysindexkeys.indid = sysindexes.indid "
-                    + " AND syscolumns.colid = sysindexkeys.colid AND syscolumns.NAME = B.NAME) as 'KEY',"
-                    + "  b.is_identity isIdentity "
-                    + " FROM sys.TABLES a " + " INNER JOIN sys.COLUMNS b ON b.object_id = a.object_id "
-                    + " LEFT JOIN sys.types ON b.user_type_id = sys.types.user_type_id   "
-                    + " LEFT JOIN sys.extended_properties c ON c.major_id = b.object_id AND c.minor_id = b.column_id "
-                    + " WHERE a.NAME = '%s' and sys.types.NAME !='sysname' ",
-            "TABLE_NAME", "COMMENTS", "COLUMN_NAME", "DATA_TYPE", "COMMENTS", "KEY"),
-
-    POSTGRE_SQL("postgre_sql", "select tablename from pg_tables where schemaname='%s' ORDER BY tablename",
-            "SELECT A.tablename, obj_description(relfilenode, 'pg_class') AS comments FROM pg_tables A, pg_class B WHERE A.schemaname='%s' AND A.tablename = B.relname",
-            "SELECT A.attname AS name, format_type(A.atttypid, A.atttypmod) AS type,col_description(A.attrelid, A.attnum) AS comment, (CASE C.contype WHEN 'p' THEN 'PRI' ELSE '' END) AS key " +
-            "FROM pg_attribute A LEFT JOIN pg_constraint C ON A.attnum = C.conkey[1] AND A.attrelid = C.conrelid " +
-            "WHERE  A.attrelid = '%s.%s'::regclass AND A.attnum > 0 AND NOT A.attisdropped ORDER  BY A.attnum",
-            "tablename", "comments", "name", "type", "comment", "key");
-
-    private final String dbType;
-    private final String tablesSql;
-    private final String tableCommentsSql;
-    private final String tableFieldsSql;
-    private final String tableName;
-    private final String tableComment;
-    private final String fieldName;
-    private final String fieldType;
-    private final String fieldComment;
-    private final String fieldKey;
-
-    QuerySQL(final String dbType, final String tablesSql, final String tableCommentsSql, final String tableFieldsSql,
-             final String tableName, final String tableComment, final String fieldName, final String fieldType,
-             final String fieldComment, final String fieldKey) {
-        this.dbType = dbType;
-        this.tablesSql = tablesSql;
-        this.tableCommentsSql = tableCommentsSql;
-        this.tableFieldsSql = tableFieldsSql;
-        this.tableName = tableName;
-        this.tableComment = tableComment;
-        this.fieldName = fieldName;
-        this.fieldType = fieldType;
-        this.fieldComment = fieldComment;
-        this.fieldKey = fieldKey;
-    }
-
-    public String getDbType() {
-        return dbType;
-    }
-
-    public String getTablesSql() {
-        return tablesSql;
-    }
-
-    public String getTableCommentsSql() {
-        return tableCommentsSql;
-    }
-
-    public String getTableFieldsSql() {
-        return tableFieldsSql;
-    }
-
-    public String getTableName() {
-        return tableName;
-    }
-
-    public String getTableComment() {
-        return tableComment;
-    }
-
-    public String getFieldName() {
-        return fieldName;
-    }
-
-    public String getFieldType() {
-        return fieldType;
-    }
-
-    public String getFieldComment() {
-        return fieldComment;
-    }
-
-    public String getFieldKey() {
-        return fieldKey;
-    }
-
-}

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/config/rules/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 代码生成器,规则相关类
- */
-package com.baomidou.mybatisplus.generator.config.rules;

+ 0 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/generator/package-info.java

@@ -1,4 +0,0 @@
-/**
- * 代码生成器相关类
- */
-package com.baomidou.mybatisplus.generator;

+ 7 - 7
mybatis-plus-generate/build.gradle

@@ -1,11 +1,11 @@
 dependencies {
     compile project(":mybatis-plus-api")
     compile rootProject.ext.dependencies["velocity"]
-    compile "org.slf4j:slf4j-api:1.7.25"
-    testCompile "com.microsoft.sqlserver:sqljdbc4:4.0"
-    testCompile "org.postgresql:postgresql:9.4.1212"
-    testCompile "com.oracle:ojdbc14:10.2.0.5.0"
-    testCompile "com.h2database:h2:1.4.194"
-    testCompile "mysql:mysql-connector-java:5.1.38"
-    testCompile "ch.qos.logback:logback-classic:1.2.2"
+    compile rootProject.ext.dependencies["slf4j-api"]
+    testCompile rootProject.ext.dependencies["sqlserver"]
+    testCompile rootProject.ext.dependencies["postgresql"]
+    testCompile rootProject.ext.dependencies["oracle"]
+    testCompile rootProject.ext.dependencies["h2"]
+    testCompile rootProject.ext.dependencies["mysql"]
+    testCompile rootProject.ext.dependencies["logback-classic"]
 }