com.baomidou.mybatisplus.generator.config.rules.NamingStrategy Java Examples

The following examples show how to use com.baomidou.mybatisplus.generator.config.rules.NamingStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MybatisPlusGenerator.java    From MI-S with MIT License 5 votes vote down vote up
/**
 * 生成策略配置
 **/
private StrategyConfig setStrategyConfig() {
    StrategyConfig strategy = new StrategyConfig();
    // strategy.setTablePrefix(new String[]{""});// 此处可以修改为您的表前缀
    strategy.setInclude(tables); // 需要生成的表
    // strategy.setExclude(new String[]{"test"}); // 排除生成的表
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    // 字段名生成策略
    // strategy.setFieldNaming(NamingStrategy.underline_to_camel);
    // 自定义实体父类
    //  strategy.setSuperEntityClass("com.mi.common.model.BaseModel");
    // 自定义实体,公共字段
    // strategy.setSuperEntityColumns(new String[] { "test_id", "age" });
    // 自定义 mapper 父类
    // strategy.setSuperMapperClass("com.baomidou.demo.TestMapper");
    // 自定义 service 父类
    // strategy.setSuperServiceClass("com.baomidou.demo.TestService");
    // 自定义 service 实现类父类
    // strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
    // 自定义 controller 父类
    // strategy.setSuperControllerClass("com.baomidou.demo.TestController");
    // 【实体】是否生成字段常量(默认 false)
    // public static final String ID = "test_id";
    // strategy.setEntityColumnConstant(true);
    // 【实体】是否为构建者模型(默认 false)
    // public User setName(String name) {this.name = name; return this;}
    // strategy.setEntityBuliderModel(true);
    strategy.setCapitalMode(true);
    return strategy;
}
 
Example #2
Source File: GeneratorServiceEntity.java    From paas with Apache License 2.0 5 votes vote down vote up
private void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
    GlobalConfig config = new GlobalConfig();
    String dbUrl = "jdbc:mysql://localhost:3306/test";
    DataSourceConfig dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setDbType(DbType.MYSQL)
            .setUrl(dbUrl)
            .setUsername("root")
            .setPassword("root")
            .setDriverName("com.mysql.jdbc.Driver");
    StrategyConfig strategyConfig = new StrategyConfig();
    strategyConfig
            .setCapitalMode(true)
            .setEntityLombokModel(false)
            .setDbColumnUnderline(true)
            .setNaming(NamingStrategy.underline_to_camel)
            .setInclude(tableNames);
    config.setActiveRecord(false)
            .setEnableCache(false) // XML 二级缓存
            .setAuthor("jitwxs")
            .setOutputDir("d:\\codeGen")
            .setFileOverride(true);
    if (!serviceNameStartWithI) {
        config.setServiceName("%sService");
    }
    new AutoGenerator().setGlobalConfig(config)
            .setDataSource(dataSourceConfig)
            .setStrategy(strategyConfig)
            .setPackageInfo(
                    new PackageConfig()
                            .setParent(packageName)
                            .setController("controller")
                            .setEntity("entity")
            ).execute();
}
 
Example #3
Source File: CodeGenUtil.java    From pre with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 策略配置
 *
 * @param tableNames 表名
 * @return StrategyConfig
 */
private StrategyConfig getStrategyConfig(String... tableNames) {

    return new StrategyConfig()
            .setEntityLombokModel(true)
            //表名生成策略  下划线转驼峰
            .setNaming(NamingStrategy.underline_to_camel)
            .setColumnNaming(NamingStrategy.underline_to_camel)
            //需要生成的的表名,多个表名传数组
            .setInclude(tableNames)
            .setRestControllerStyle(true)
            .setControllerMappingHyphenStyle(true);
}
 
Example #4
Source File: GeneratorServiceEntity.java    From express-ssm with Apache License 2.0 5 votes vote down vote up
private void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
    GlobalConfig config = new GlobalConfig();
    String dbUrl = "jdbc:mysql://localhost:3306/express";
    DataSourceConfig dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setDbType(DbType.MYSQL)
            .setUrl(dbUrl)
            .setUsername("root")
            .setPassword("root")
            .setDriverName("com.mysql.jdbc.Driver");
    StrategyConfig strategyConfig = new StrategyConfig();
    strategyConfig
            .setCapitalMode(true)
            .setEntityLombokModel(false)
            .setDbColumnUnderline(true)
            .setNaming(NamingStrategy.underline_to_camel)
            .setInclude(tableNames);
    config.setActiveRecord(false)
            .setEnableCache(false) // XML 二级缓存
            .setAuthor("jitwxs")
            .setOutputDir("d:\\codeGen")
            .setFileOverride(true);
    if (!serviceNameStartWithI) {
        config.setServiceName("%sService");
    }
    new AutoGenerator().setGlobalConfig(config)
            .setDataSource(dataSourceConfig)
            .setStrategy(strategyConfig)
            .setPackageInfo(
                    new PackageConfig()
                            .setParent(packageName)
                            .setController("controller")
                            .setEntity("pojo")
            ).execute();
}
 
Example #5
Source File: GeneratorServiceEntity.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
private void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
    GlobalConfig config = new GlobalConfig();
    String dbUrl = "jdbc:mysql://localhost:3306/payment";
    DataSourceConfig dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setDbType(DbType.MYSQL)
            .setUrl(dbUrl)
            .setUsername("root")
            .setPassword("root")
            .setDriverName("com.mysql.jdbc.Driver");
    StrategyConfig strategyConfig = new StrategyConfig();
    strategyConfig
            .setCapitalMode(true)
            .setEntityLombokModel(false)
            .setDbColumnUnderline(true)
            .setNaming(NamingStrategy.underline_to_camel)
            .setInclude(tableNames);
    config.setActiveRecord(false)
            .setEnableCache(false) // XML 二级缓存
            .setAuthor("jitwxs")
            .setOutputDir("d:\\codeGen")
            .setFileOverride(true);
    if (!serviceNameStartWithI) {
        config.setServiceName("%sService");
    }
    new AutoGenerator().setGlobalConfig(config)
            .setDataSource(dataSourceConfig)
            .setStrategy(strategyConfig)
            .setPackageInfo(
                    new PackageConfig()
                            .setParent(packageName)
                            .setController("controller")
                            .setEntity("entity")
            ).execute();
}
 
Example #6
Source File: GeneratorServiceEntity.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
private void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
    GlobalConfig config = new GlobalConfig();
    String dbUrl = "jdbc:mysql://localhost:3306/test1";
    DataSourceConfig dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setDbType(DbType.MYSQL)
            .setUrl(dbUrl)
            .setUsername("root")
            .setPassword("root")
            .setDriverName("com.mysql.jdbc.Driver");
    StrategyConfig strategyConfig = new StrategyConfig();
    strategyConfig
            .setCapitalMode(true)
            .setEntityLombokModel(false)
            .setDbColumnUnderline(true)
            .setNaming(NamingStrategy.underline_to_camel)
            .setInclude(tableNames);
    config.setActiveRecord(false)
            .setEnableCache(false) // XML 二级缓存
            .setAuthor("jitwxs")
            .setOutputDir("d:\\codeGen")
            .setFileOverride(true);
    if (!serviceNameStartWithI) {
        config.setServiceName("I%sService");
    }
    new AutoGenerator().setGlobalConfig(config)
            .setDataSource(dataSourceConfig)
            .setStrategy(strategyConfig)
            .setPackageInfo(
                    new PackageConfig()
                            .setParent(packageName)
                            .setController("controller")
                            .setEntity("entity")
            ).execute();
}
 
Example #7
Source File: GenerateService.java    From cola-cloud with MIT License 4 votes vote down vote up
@PostConstruct
public void init(){

    globalConfig= new GlobalConfig();
    globalConfig.setFileOverride(true);
    globalConfig.setActiveRecord(false);
    // XML 二级缓存
    globalConfig.setEnableCache(false);
    // XML ResultMap
    globalConfig.setBaseResultMap(false);
    // XML columList
    globalConfig.setBaseColumnList(false);
    // 自定义文件命名,注意 %s 会自动填充表实体属性!
    globalConfig.setMapperName("%sMapper");
    globalConfig.setXmlName("%sMapper");
    globalConfig.setServiceName("%sService");
    globalConfig.setServiceImplName("%sServiceImpl");
    globalConfig.setControllerName("%sController");

    // 数据源配置
    dataSourceConfig = new DataSourceConfig();
    dataSourceConfig.setDbType(DbType.MYSQL);
    dataSourceConfig.setTypeConvert(new MySqlTypeConvert(){
        // 自定义数据库表字段类型转换【可选】
        @Override
        public DbColumnType processTypeConvert(String fieldType) {
            System.out.println("转换类型:" + fieldType);
            // 注意!!processTypeConvert 存在默认类型转换,如果不是你要的效果请自定义返回、非如下直接返回。
            return super.processTypeConvert(fieldType);
        }
    });
    dataSourceConfig.setDriverName(dataSourceProperties.getDriverClassName());
    dataSourceConfig.setUsername(dataSourceProperties.getUsername());
    dataSourceConfig.setPassword(dataSourceProperties.getPassword());
    dataSourceConfig.setUrl(dataSourceProperties.getUrl());

    // 策略配置
    strategyConfig = new StrategyConfig();
    // 表名生成策略
    strategyConfig.setNaming(NamingStrategy.underline_to_camel);
    // 需要生成的表
    // 自定义 service 父类
    strategyConfig.setSuperServiceClass("com.honvay.cola.cloud.framework.base.service.BaseService");
    // 自定义 service 实现类父类
    strategyConfig.setSuperServiceImplClass("com.honvay.cola.cloud.framework.base.service.impl.BaseServiceImpl");
    // 自定义 controller 父类
    strategyConfig.setSuperControllerClass("com.honvay.cola.cloud.framework.base.controller.BaseController");
    strategyConfig.setEntityLombokModel(true);
    strategyConfig.setRestControllerStyle(true);
    strategyConfig.setEntityBuilderModel(true);


    packageConfig = new PackageConfig();
    packageConfig.setController("controller");
    packageConfig.setEntity("entity");
    packageConfig.setMapper("mapper");
    packageConfig.setService("service");
    packageConfig.setServiceImpl("service.impl");

    entityNameRewriter = new EntityNameRewriter();

}
 
Example #8
Source File: CodeGenerator.java    From kvf-admin with MIT License 4 votes vote down vote up
private static void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
        GlobalConfig config = new GlobalConfig();
        DataSourceConfig dataSourceConfig = new DataSourceConfig();
        dataSourceConfig.setDbType(DbType.MYSQL).setUrl(dbUrl).setUsername(dbUsername).setPassword(dbPassword)
                .setDriverName("com.mysql.jdbc.Driver").setTypeConvert((globalConfig, s) -> {
            if (s.contains("tinyint(1)")) { // 自定义数据库表字段类型转换
                return DbColumnType.INTEGER;
            }
            return new MySqlTypeConvert().processTypeConvert(globalConfig, s);
        });
        StrategyConfig strategyConfig = new StrategyConfig();
        strategyConfig
                .setCapitalMode(true)
                .setEntityLombokModel(true)
//                .setDbColumnUnderline(true)
                .setTablePrefix(tablePrefix)
                .setNaming(NamingStrategy.underline_to_camel)
                .setInclude(tableNames)//修改替换成你需要的表名,多个表名传数组
                .setRestControllerStyle(true)
                .setSuperEntityClass("com.kalvin.kvf.common.entity.BaseEntity")
                .setSuperControllerClass("com.kalvin.kvf.common.controller.BaseController");

        config.setActiveRecord(false)
                .setAuthor(author)
                .setOutputDir(outputDir)
                .setFileOverride(true)
                .setEnableCache(false)
                .setBaseResultMap(true)
                .setBaseColumnList(true);
        TemplateConfig tc = new TemplateConfig();
        if (!serviceNameStartWithI) {
            config.setServiceName("%sService");
            config.setMapperName("%sMapper");
        }
        new AutoGenerator().setGlobalConfig(config)
                .setTemplate(tc)
                .setDataSource(dataSourceConfig)
                .setStrategy(strategyConfig)
                .setPackageInfo(
                        new PackageConfig()
                                .setParent(packageName)
                                .setEntity("entity.sys")
                                .setMapper("mapper.sys")
                                .setController("controller.sys")
                                .setService("service.sys")
                                .setServiceImpl("service.sys")
                                .setXml("xml.sys")
                ).execute();
    }
 
Example #9
Source File: Generator.java    From Nickle-Scheduler with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        gc.setBaseResultMap(true);
        gc.setBaseColumnList(true);
        String projectPath = System.getProperty("user.dir")+"/Scheduler-Server";
        gc.setOutputDir(projectPath + "/src/main/java");
        gc.setAuthor("nickle");
        gc.setOpen(false);
        // gc.setSwagger2(true); 实体属性 Swagger2 注解
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://10.155.10.38:4502/nickle-scheduler?Unicode=true&characterEncoding=UTF-8");
        // dsc.setSchemaName("public");
        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
        dsc.setUsername("shark_dev");
        dsc.setPassword("shark_dev");
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setModuleName("server");
        pc.setParent("nickle.scheduler");
        mpg.setPackageInfo(pc);

        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };

        // 如果模板引擎是 freemarker
        //String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
        focList.add(new FileOutConfig() {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        /*
        cfg.setFileCreate(new IFileCreate() {
            @Override
            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
                // 判断自定义文件夹是否需要创建
                checkDir("调用默认方法创建的目录");
                return false;
            }
        });
        */
        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        //templateConfig.setXml(null);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        //strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
        strategy.setEntityLombokModel(true);
        strategy.setRestControllerStyle(true);
        //strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
//        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
//        strategy.setSuperEntityColumns("id");
        strategy.setControllerMappingHyphenStyle(true);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        mpg.setStrategy(strategy);
        mpg.setTemplateEngine(new VelocityTemplateEngine());
        mpg.execute();
    }
 
Example #10
Source File: AdminMpGenerator.java    From charging_pile_cloud with MIT License 4 votes vote down vote up
public static void main(String[] args) {
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        gc.setOutputDir("D:\\code");
        gc.setAuthor("kongling");
        gc.setOpen(true);
        gc.setSwagger2(false);
        gc.setDateType(DateType.ONLY_DATE);
        gc.setBaseResultMap(true);
        gc.setBaseColumnList(true);
        gc.setSwagger2(true);
        gc.setActiveRecord(true);
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://127.0.0.1:3306/charging_pile?serverTimezone=UTC");
        // dsc.setSchemaName("public");
        dsc.setDriverName("com.mysql.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("root");
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        //pc.setModuleName(scanner("模块名"));
        pc.setParent(scanner("包名,例如:com.sskj.admin"));
        mpg.setPackageInfo(pc);
        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };

        // 如果模板引擎是 freemarker
        String templatePath = "/templates/mapper.xml";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
/*
		focList.add(new FileOutConfig(templatePath) {
			@Override
			public String outputFile(TableInfo tableInfo) {
				// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
				return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
						+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
			}
		});
*/

        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        templateConfig.setXml(templatePath);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        //	strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
        //RestController
        strategy.setRestControllerStyle(false);
        //strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
        strategy.setInclude(scanner("表名"));
      //  strategy.setSuperEntityColumns("id");
        strategy.setControllerMappingHyphenStyle(false);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        strategy.setEntityTableFieldAnnotationEnable(true);
        strategy.setEntityLombokModel(true);
        /**
         * boolean 是否一处前缀is
         */
        strategy. setEntityBooleanColumnRemoveIsPrefix(false);
        mpg.setStrategy(strategy);
        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
        mpg.execute();
    }
 
Example #11
Source File: CodeGenerator.java    From springboot-restful-starter with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    String projectPath = System.getProperty("user.dir");
    gc.setOutputDir(projectPath + "/src/main/java");
    gc.setAuthor(AUTHOR);
    gc.setOpen(false);
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setUrl("jdbc:mysql://localhost:3306/"+DATABASE+"?serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&characterEncoding=utf8");
    // dsc.setSchemaName("public");
    dsc.setDriverName("com.mysql.cj.jdbc.Driver");
    dsc.setUsername(DATABASE_USERNAME);
    dsc.setPassword(DATABASE_PASSWORD);
    mpg.setDataSource(dsc);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setModuleName(scanner("模块名"));
    pc.setParent(PROJECT);
    mpg.setPackageInfo(pc);

    // 自定义配置
    // InjectionConfig cfg = new InjectionConfig() {
    //     @Override
    //     public void initMap() {
    //         // to do nothing
    //     }
    // };
    // List<FileOutConfig> focList = new ArrayList<>();
    // focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
    //     @Override
    //     public String outputFile(TableInfo tableInfo) {
    //         // 自定义输入文件名称
    //         return projectPath + "/src/main/resources/mapper/" + pc.getModuleName() + "/"
    //                 + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
    //     }
    // });
    // cfg.setFileOutConfigList(focList);
    // mpg.setCfg(cfg);
    // mpg.setTemplate(new TemplateConfig().setXml(null));

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    strategy.setNaming(NamingStrategy.underline_to_camel);
    strategy.setColumnNaming(NamingStrategy.underline_to_camel);
    //strategy.setSuperEntityClass(PROJECT + ".base.BaseEntity");     // 自定义实体类继承
    strategy.setEntityLombokModel(true);
    strategy.setRestControllerStyle(true);
    //strategy.setSuperControllerClass(PROJECT + ".base.BaseController");     // 自定义控制器继承
    strategy.setInclude(scanner("表名"));
    strategy.setSuperEntityColumns("id");
    strategy.setControllerMappingHyphenStyle(true);
    strategy.setTablePrefix(pc.getModuleName() + "_");
    mpg.setStrategy(strategy);
    mpg.setTemplateEngine(new FreemarkerTemplateEngine());
    mpg.execute();
}
 
Example #12
Source File: CodeGenerator2.java    From kvf-admin with MIT License 4 votes vote down vote up
public static void main(String[] args) {
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        System.out.println("projectPath = " + projectPath);
        gc.setOutputDir(projectPath + "/src/main/java");
        gc.setAuthor("Kalvin");
        gc.setOpen(false);
        gc.setIdType(IdType.AUTO);
        // gc.setSwagger2(true); 实体属性 Swagger2 注解
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://localhost:3306/activiti_k?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=GMT%2B8");
        // dsc.setSchemaName("public");
        dsc.setDriverName("com.mysql.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("root");
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setModuleName(scanner("模块名"));
        pc.setParent("com.kalvin");
        mpg.setPackageInfo(pc);

        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };

        // 如果模板引擎是 freemarker
//        String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
         String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
        focList.add(new FileOutConfig(templatePath) {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        /*
        cfg.setFileCreate(new IFileCreate() {
            @Override
            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
                // 判断自定义文件夹是否需要创建
                checkDir("调用默认方法创建的目录");
                return false;
            }
        });
        */
        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        templateConfig.setXml(null);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        strategy.setSuperEntityClass("com.kalvin.kvf.common.entity.BaseEntity");
        strategy.setEntityLombokModel(true);
        strategy.setRestControllerStyle(true);
        strategy.setSuperControllerClass("com.kalvin.kvf.common.controller.BaseController");
        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
        strategy.setSuperEntityColumns("id");
        strategy.setControllerMappingHyphenStyle(true);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        mpg.setStrategy(strategy);
//        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
        mpg.execute();
    }
 
Example #13
Source File: PigResourcesGenerator.java    From pig with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    String outputDir = "/Users/lengleng/work/temp";
    final String viewOutputDir = outputDir + "/view/";
    AutoGenerator mpg = new AutoGenerator();
    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir(outputDir);
    gc.setFileOverride(true);
    gc.setActiveRecord(true);
    // XML 二级缓存
    gc.setEnableCache(false);
    // XML ResultMap
    gc.setBaseResultMap(true);
    // XML columList
    gc.setBaseColumnList(true);
    gc.setAuthor("lengleng");
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("lengleng");
    dsc.setUrl("jdbc:mysql://139.224.200.249:3309/pig?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false");
    mpg.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
    strategy.setSuperControllerClass("com.github.pig.common.web.BaseController");
    // 表名生成策略
    strategy.setNaming(NamingStrategy.underline_to_camel);
    mpg.setStrategy(strategy);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent("com.github.pig.admin");
    pc.setController("controller");
    mpg.setPackageInfo(pc);

    // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
        }
    };
    // 生成的模版路径,不存在时需要先新建
    File viewDir = new File(viewOutputDir);
    if (!viewDir.exists()) {
        viewDir.mkdirs();
    }
    List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
    focList.add(new FileOutConfig("/templates/listvue.vue.vm") {
        @Override
        public String outputFile(TableInfo tableInfo) {
            return getGeneratorViewPath(viewOutputDir, tableInfo, ".vue");
        }
    });
    cfg.setFileOutConfigList(focList);
    mpg.setCfg(cfg);


    //生成controller相关
    mpg.execute();
}
 
Example #14
Source File: GeneratorService.java    From spring-cloud-shop with MIT License 4 votes vote down vote up
/**
 * 自动生成代码
 *
 * @param tableSchema 数据库空间
 * @param tableName   表名
 */
public Response generator(String tableSchema, String tableName) {

    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    String projectPath = System.getProperty("user.dir");
    gc.setOutputDir(projectPath + "/shop/src/main/java");
    gc.setAuthor(System.getProperty("user.name"));
    gc.setOpen(false);
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setUrl(MessageFormat.format("jdbc:mysql://localhost:3306/{0}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false", tableSchema));
    dsc.setDriverName("com.mysql.cj.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("root");
    mpg.setDataSource(dsc);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setModuleName("shop");
    pc.setParent("quick.pager.shop");
    mpg.setPackageInfo(pc);

    // 自定义配置
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            // to do nothing
        }
    };
    List<FileOutConfig> focList = new ArrayList<>();
    focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
        @Override
        public String outputFile(TableInfo tableInfo) {
            // 自定义输入文件名称
            return projectPath + "/shop/src/main/resources/mapper/" + pc.getModuleName()
                    + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
        }
    });
    cfg.setFileOutConfigList(focList);
    mpg.setCfg(cfg);
    mpg.setTemplate(new TemplateConfig().setXml(null));

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    strategy.setNaming(NamingStrategy.underline_to_camel);
    strategy.setColumnNaming(NamingStrategy.underline_to_camel);
    strategy.setSuperEntityClass("quick.pager.shop.model.Model");
    strategy.setEntityLombokModel(true);
    strategy.setInclude(tableName);
    strategy.setSuperEntityColumns("id");
    strategy.setControllerMappingHyphenStyle(true);
    strategy.setTablePrefix(pc.getModuleName() + "_");
    mpg.setStrategy(strategy);
    mpg.setTemplateEngine(new FreemarkerTemplateEngine());
    mpg.execute();

    return new Response();
}
 
Example #15
Source File: CodeGenerator.java    From oauth-boot with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();


    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    String projectPath = System.getProperty("user.dir");
    gc.setOutputDir(projectPath + "/src/main/java");
    gc.setAuthor("jobob");
    gc.setOpen(false);
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setUrl("jdbc:mysql://:3306/ant?useUnicode=true&useSSL=false&characterEncoding=utf8");
    // dsc.setSchemaName("public");
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("密码");
    mpg.setDataSource(dsc);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setModuleName(scanner("模块名"));
    pc.setParent("com.baomidou.ant");
    mpg.setPackageInfo(pc);

    // 自定义配置
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            // to do nothing
        }
    };
    List<FileOutConfig> focList = new ArrayList<>();
    focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
        @Override
        public String outputFile(TableInfo tableInfo) {
            // 自定义输入文件名称
            return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
                    + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
        }
    });
    cfg.setFileOutConfigList(focList);
    mpg.setCfg(cfg);
    mpg.setTemplate(new TemplateConfig().setXml(null));

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    strategy.setNaming(NamingStrategy.underline_to_camel);
    strategy.setColumnNaming(NamingStrategy.underline_to_camel);
    strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
    strategy.setEntityLombokModel(true);
    strategy.setRestControllerStyle(true);
    strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
    strategy.setInclude(scanner("表名"));
    strategy.setSuperEntityColumns("id");
    strategy.setControllerMappingHyphenStyle(true);
    strategy.setTablePrefix(pc.getModuleName() + "_");
    mpg.setStrategy(strategy);
    mpg.setTemplateEngine(new FreemarkerTemplateEngine());
    mpg.execute();
}
 
Example #16
Source File: BladeCodeGenerator.java    From blade-tool with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void run() {
	Properties props = getProperties();
	AutoGenerator mpg = new AutoGenerator();
	GlobalConfig gc = new GlobalConfig();
	String outputDir = getOutputDir();
	String author = props.getProperty("author");
	gc.setOutputDir(outputDir);
	gc.setAuthor(author);
	gc.setFileOverride(true);
	gc.setOpen(false);
	gc.setActiveRecord(false);
	gc.setEnableCache(false);
	gc.setBaseResultMap(true);
	gc.setBaseColumnList(true);
	gc.setMapperName("%sMapper");
	gc.setXmlName("%sMapper");
	gc.setServiceName("I%sService");
	gc.setServiceImplName("%sServiceImpl");
	gc.setControllerName("%sController");
	gc.setSwagger2(isSwagger2);
	mpg.setGlobalConfig(gc);
	DataSourceConfig dsc = new DataSourceConfig();
	String driverName = Func.toStr(this.driverName, props.getProperty("spring.datasource.driver-class-name"));
	if (StringUtil.containsAny(driverName, DbType.MYSQL.getDb())) {
		dsc.setDbType(DbType.MYSQL);
		dsc.setTypeConvert(new MySqlTypeConvert());
	} else if (StringUtil.containsAny(driverName, DbType.POSTGRE_SQL.getDb())) {
		dsc.setDbType(DbType.POSTGRE_SQL);
		dsc.setTypeConvert(new PostgreSqlTypeConvert());
	} else {
		dsc.setDbType(DbType.ORACLE);
		dsc.setTypeConvert(new OracleTypeConvert());
	}
	dsc.setDriverName(driverName);
	dsc.setUrl(Func.toStr(this.url, props.getProperty("spring.datasource.url")));
	dsc.setUsername(Func.toStr(this.username, props.getProperty("spring.datasource.username")));
	dsc.setPassword(Func.toStr(this.password, props.getProperty("spring.datasource.password")));
	mpg.setDataSource(dsc);
	// 策略配置
	StrategyConfig strategy = new StrategyConfig();
	// strategy.setCapitalMode(true);// 全局大写命名
	// strategy.setDbColumnUnderline(true);//全局下划线命名
	strategy.setNaming(NamingStrategy.underline_to_camel);
	strategy.setColumnNaming(NamingStrategy.underline_to_camel);
	strategy.setTablePrefix(tablePrefix);
	if (includeTables.length > 0) {
		strategy.setInclude(includeTables);
	}
	if (excludeTables.length > 0) {
		strategy.setExclude(excludeTables);
	}
	if (hasSuperEntity) {
		strategy.setSuperEntityClass("org.springblade.core.mp.base.BaseEntity");
		strategy.setSuperEntityColumns(superEntityColumns);
		strategy.setSuperServiceClass("org.springblade.core.mp.base.BaseService");
		strategy.setSuperServiceImplClass("org.springblade.core.mp.base.BaseServiceImpl");
	} else {
		strategy.setSuperServiceClass("com.baomidou.mybatisplus.extension.service.IService");
		strategy.setSuperServiceImplClass("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl");
	}
	// 自定义 controller 父类
	strategy.setSuperControllerClass("org.springblade.core.boot.ctrl.BladeController");
	strategy.setEntityBuilderModel(false);
	strategy.setEntityLombokModel(true);
	strategy.setControllerMappingHyphenStyle(true);
	mpg.setStrategy(strategy);
	// 包配置
	PackageConfig pc = new PackageConfig();
	// 控制台扫描
	pc.setModuleName(null);
	pc.setParent(packageName);
	pc.setController("controller");
	pc.setEntity("entity");
	pc.setXml("mapper");
	mpg.setPackageInfo(pc);
	mpg.setCfg(getInjectionConfig());
	mpg.execute();
}
 
Example #17
Source File: CodeGeneration.java    From poseidon with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	AutoGenerator mpg = new AutoGenerator();
	// 全局配置
	GlobalConfig gc = new GlobalConfig();
	gc.setOutputDir(
			"/media/code/program/java/poseidon/poseidon/psd-web-view/src/main/java");
	gc.setFileOverride(true);
	gc.setActiveRecord(false);// 不需要ActiveRecord特性的请改为false
	gc.setEnableCache(false);// XML 二级缓存
	gc.setBaseResultMap(true);// XML ResultMap
	gc.setBaseColumnList(false);// XML columList
	gc.setAuthor("yoke");// 作者

	// 自定义文件命名,注意 %s 会自动填充表实体属性!
	gc.setControllerName("%sController");
	gc.setServiceName("%sService");
	gc.setServiceImplName("%sServiceImpl");
	gc.setMapperName("%sMapper");
	gc.setXmlName("%sMapper");
	mpg.setGlobalConfig(gc);

	// 数据源配置
	DataSourceConfig dsc = new DataSourceConfig();
	dsc.setDbType(DbType.MYSQL);
	dsc.setDriverName("com.mysql.cj.jdbc.Driver");
	dsc.setUsername("root");
	dsc.setPassword("FJEOIRFWQ132EW");
	dsc.setUrl(
			"jdbc:mysql://www.test.com:13306/poseidon?useUnicode=true&characterEncoding=utf-8&useSSL=false");
	mpg.setDataSource(dsc);

	// 策略配置
	StrategyConfig strategy = new StrategyConfig();
	strategy.setTablePrefix("db_");// 此处可以修改为您的表前缀
	strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
	strategy.setInclude("db_item_attribute_name", "db_item_attribute_value",
			"db_item_sku");
	strategy.setSuperServiceClass(null);
	strategy.setSuperServiceImplClass(null);
	strategy.setSuperMapperClass(null);
	mpg.setStrategy(strategy);

	// 包配置
	PackageConfig pc = new PackageConfig();
	pc.setParent("com.yoke.poseidon.web.itemShow");
	pc.setController("web");
	pc.setService("service");
	pc.setServiceImpl("serviceImpl");
	pc.setMapper("mapper");
	pc.setEntity("entity");
	pc.setXml("mapper");
	mpg.setPackageInfo(pc);
	// 执行生成
	mpg.execute();

}
 
Example #18
Source File: MBPlusTest.java    From Resource with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args)
{
    AutoGenerator ag = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    //gc.setOutputDir("D:\\workspace\\SpringBoot\\src\\main\\java");//将代码生成在项目中
    gc.setOutputDir(System.getProperty("user.dir") + "/src/main/java");//将代码生成在指定目录中
    gc.setFileOverride(true);
    gc.setActiveRecord(false);  // 不需要ActiveRecord特性的请改为false
    gc.setEnableCache(false);   // XML 二级缓存
    gc.setBaseResultMap(true);  // XML ResultMap
    gc.setBaseColumnList(false);// XML columnList
    gc.setAuthor("zsm");        // 作者
    gc.setDateType(DateType.ONLY_DATE);//只生成java.util.Date类型时间格式

    // 自定义文件命名,注意 %s 会自动填充表实体属性
    gc.setControllerName("%sController");
    gc.setServiceName("%sService");
    gc.setServiceImplName("%sServiceImpl");
    gc.setMapperName("%sMapper");
    gc.setXmlName("%sMapper");
    ag.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    //设置数据库类型
    dsc.setDbType(DbType.MYSQL);
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("123456");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test_db?characterEncoding=utf-8");
    ag.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    // strategy.setCapitalMode(true);   // 全局大写命名 ORACLE 注意
    strategy.setTablePrefix(new String[] {"tb_"});       // 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);  // 表名生成策略
    strategy.setInclude(new String[] {"tb_user", "tb_order"}); // 需要生成的表
    // strategy.setExclude(new String[]{"tb_test"});   // 排除生成的表

    strategy.setSuperServiceClass(null);        // 自定义 service 父类
    strategy.setSuperServiceImplClass(null);
    strategy.setSuperMapperClass(null);
    // 自定义实体父类
    //strategy.setSuperEntityClass(com.zsm.sb.entity.BaseEntity);
    // 自定义实体,公共字段
    //strategy.setSuperEntityColumns(new String[] { "test_id", "userId" });
    // 自定义 mapper 父类
    // strategy.setSuperMapperClass("com.zsm.sb.mapper.BaseMapper");
    // 自定义 service 父类
    // strategy.setSuperServiceClass("com.zsm.sb.service.BaseService");
    // 自定义 service 实现类父类
    // strategy.setSuperServiceImplClass("com.zsm.sb.service.BaseServiceImpl");
    // 自定义 controller 父类
    // strategy.setSuperControllerClass("com.zsm.sb.controller.BaseController");
    // 实体是否生成字段常量(默认 false)
    // public static final String ID = "userId";
    // strategy.setEntityColumnConstant(true);
    // 实体是否为构建者模型(默认 false)
    // public User setName(String name) {this.name = name; return this;}
    //strategy.setEntityBuilderModel(true);
    ag.setStrategy(strategy);

    // 生成代码包名配置
    PackageConfig pc = new PackageConfig();
    pc.setParent("com.zsm.sb");
    pc.setController("controller");
    pc.setService("service");
    pc.setServiceImpl("service.impl");
    pc.setMapper("dao");
    pc.setEntity("model");
    pc.setXml("mapper");
    ag.setPackageInfo(pc);

    // 自定义 xxList.jsp 生成
    List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
    // focList.add(new FileOutConfig("/template/list.jsp.vm") {
    // @Override
    // public String outputFile(TableInfo tableInfo) {
    // // 自定义输入文件名称
    // return "D://my_" + tableInfo.getEntityName() + ".jsp";
    // }
    // });
    // cfg.setFileOutConfigList(focList);
    // mpg.setCfg(cfg);

    // 执行生成
    ag.execute();
}
 
Example #19
Source File: EntityGenerator.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Test
public void entityGenerator() {
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-user\\src\\main\\java");//这里写你自己的java目录
    gc.setFileOverride(true);//是否覆盖
    gc.setActiveRecord(true);
    gc.setEnableCache(false);// XML 二级缓存
    gc.setBaseResultMap(true);// XML ResultMap
    gc.setBaseColumnList(false);// XML columList
    gc.setAuthor("jiangzh");
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setTypeConvert(new MySqlTypeConvert() {
        // 自定义数据库表字段类型转换【可选】
        @Override
        public DbColumnType processTypeConvert(String fieldType) {
            return super.processTypeConvert(fieldType);
        }
    });
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
    mpg.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    strategy.setInclude(new String[]{"mooc_user_t"});
    mpg.setStrategy(strategy);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent(null);
    pc.setEntity("com.stylefeng.guns.rest.common.persistence.model");
    pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao");
    pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping");
    pc.setService("TTT");       //本项目没用,生成之后删掉
    pc.setServiceImpl("TTT");   //本项目没用,生成之后删掉
    pc.setController("TTT");    //本项目没用,生成之后删掉
    mpg.setPackageInfo(pc);

    // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            Map<String, Object> map = new HashMap<>();
            map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
            this.setMap(map);
        }
    };
    mpg.setCfg(cfg);

    // 执行生成
    mpg.execute();

    // 打印注入设置
    System.err.println(mpg.getCfg().getMap().get("abc"));
}
 
Example #20
Source File: CodeGenerator.java    From supplierShop with MIT License 4 votes vote down vote up
public static String underlineToCamel(String underline){
    if (StringUtils.isNotBlank(underline)){
        return NamingStrategy.underlineToCamel(underline);
    }
    return null;
}
 
Example #21
Source File: CodeGenerator.java    From supplierShop with MIT License 4 votes vote down vote up
public static String underlineToPascal(String underline){
    if (StringUtils.isNotBlank(underline)){
        return NamingStrategy.capitalFirst(NamingStrategy.underlineToCamel(underline));
    }
    return null;
}
 
Example #22
Source File: CodeGeneratorUtils.java    From spring-boot-shiro with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        gc.setOutputDir(projectPath + "/src/main/java");
        gc.setAuthor(AUTHOR);
        gc.setOpen(false);
//        gc.setSwagger2(true);
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl(String.format("jdbc:mysql://%s:3306/%s?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC", HOST, DATABASE_NAME));
        // dsc.setSchemaName("public");
        dsc.setDriverName(DRIVER_CLASS_NAME);
        dsc.setUsername(DATABASE_USERNAME);
        dsc.setPassword(DATABASE_PASSWORD);
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setModuleName(scanner("模块名"));
        pc.setParent(PARENT_PACKAGE);
        mpg.setPackageInfo(pc);

        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };

        // 如果模板引擎是 freemarker
        String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
        focList.add(new FileOutConfig(templatePath) {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        /*
        cfg.setFileCreate(new IFileCreate() {
            @Override
            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
                // 判断自定义文件夹是否需要创建
                checkDir("调用默认方法创建的目录");
                return false;
            }
        });
        */
        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        templateConfig.setXml(null);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
//        strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
        strategy.setEntityLombokModel(true);
        strategy.setRestControllerStyle(true);
//        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
        strategy.setSuperEntityColumns("id");
        strategy.setControllerMappingHyphenStyle(true);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        mpg.setStrategy(strategy);
        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
        mpg.execute();
    }
 
Example #23
Source File: MysqlGenerator.java    From spring-boot-demo with MIT License 4 votes vote down vote up
/**
 * RUN THIS
 */
public static void main(String[] args) {
    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    final String projectPath = System.getProperty("user.dir");
    gc.setOutputDir(projectPath + "/mybatis-plus-generator/merchantplatform/src/main/java");
    gc.setAuthor("bbx");
    gc.setOpen(false);
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setUrl("jdbc:mysql://bbx-testdb-out.mysql.rds.aliyuncs.com:3306/bbx_test?useSSL=false&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8");
    // dsc.setSchemaName("public");
    dsc.setDriverName("com.mysql.cj.jdbc.Driver");
    dsc.setUsername("bbx_root");
    dsc.setPassword("LHBbx#2017@15");
    mpg.setDataSource(dsc);

    // 包配置
    final PackageConfig pc = new PackageConfig();
    pc.setModuleName(scanner("模块名"));
    pc.setParent("com.bbx.merchantplatform");
    mpg.setPackageInfo(pc);

    // 自定义配置
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            // to do nothing
        }
    };
    List<FileOutConfig> focList = new ArrayList<>();
    focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
        @Override
        public String outputFile(TableInfo tableInfo) {
            // 自定义输入文件名称
            return projectPath + "/mybatis-plus-generator/merchantplatform/src/main/resources/mapper/" + pc.getModuleName()
                    + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
        }
    });
    cfg.setFileOutConfigList(focList);
    mpg.setCfg(cfg);
    mpg.setTemplate(new TemplateConfig().setXml(null));

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    strategy.setNaming(NamingStrategy.underline_to_camel);
    strategy.setColumnNaming(NamingStrategy.underline_to_camel);
    strategy.setSuperEntityClass("com.bbx.merchantplatform.common.base.BaseEntity");
    strategy.setEntityLombokModel(true);
    strategy.setSuperControllerClass("com.bbx.merchantplatform.common.base.BaseController");
    strategy.setInclude(scanner("表名"));
    strategy.setSuperEntityColumns("id");
    strategy.setControllerMappingHyphenStyle(true);
    strategy.setTablePrefix(pc.getModuleName() + "_");
    mpg.setStrategy(strategy);
    // 选择 freemarker 引擎需要指定如下加,注意 pom 依赖必须有!
    mpg.setTemplateEngine(new FreemarkerTemplateEngine());
    mpg.execute();
}
 
Example #24
Source File: EntityGenerator.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Test
public void entityGenerator() {
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-alipay\\src\\main\\java");//这里写你自己的java目录
    gc.setFileOverride(true);//是否覆盖
    gc.setActiveRecord(true);
    gc.setEnableCache(false);// XML 二级缓存
    gc.setBaseResultMap(true);// XML ResultMap
    gc.setBaseColumnList(false);// XML columList
    gc.setAuthor("jiangzh");
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setTypeConvert(new MySqlTypeConvert() {
        // 自定义数据库表字段类型转换【可选】
        @Override
        public DbColumnType processTypeConvert(String fieldType) {
            return super.processTypeConvert(fieldType);
        }
    });
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
    mpg.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    strategy.setInclude(new String[]{"mooc_order_2017_t"});
    mpg.setStrategy(strategy);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent(null);
    pc.setEntity("com.stylefeng.guns.rest.common.persistence.model");
    pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao");
    pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping");
    pc.setService("TTT");       //本项目没用,生成之后删掉
    pc.setServiceImpl("TTT");   //本项目没用,生成之后删掉
    pc.setController("TTT");    //本项目没用,生成之后删掉
    mpg.setPackageInfo(pc);

    // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            Map<String, Object> map = new HashMap<>();
            map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
            this.setMap(map);
        }
    };
    mpg.setCfg(cfg);

    // 执行生成
    mpg.execute();

    // 打印注入设置
    System.err.println(mpg.getCfg().getMap().get("abc"));
}
 
Example #25
Source File: WebGeneratorConfig.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Override
protected void config() {
    /**
     * 数据库配置
     */
    dataSourceConfig.setDbType(DbType.MYSQL);
    dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
    dataSourceConfig.setUsername(genQo.getUserName());
    dataSourceConfig.setPassword(genQo.getPassword());
    dataSourceConfig.setUrl(genQo.getUrl());

    /**
     * 全局配置
     */
    globalConfig.setOutputDir(genQo.getProjectPath() + File.separator + "src" + File.separator + "main" + File.separator + "java");
    globalConfig.setFileOverride(true);
    globalConfig.setEnableCache(false);
    globalConfig.setBaseResultMap(true);
    globalConfig.setBaseColumnList(true);
    globalConfig.setOpen(false);
    globalConfig.setAuthor(genQo.getAuthor());
    contextConfig.setProPackage(genQo.getProjectPackage());
    contextConfig.setCoreBasePackage(genQo.getCorePackage());

    /**
     * 生成策略
     */
    if (genQo.getIgnoreTabelPrefix() != null) {
        strategyConfig.setTablePrefix(new String[]{genQo.getIgnoreTabelPrefix()});
    }
    strategyConfig.setInclude(new String[]{genQo.getTableName()});
    strategyConfig.setNaming(NamingStrategy.underline_to_camel);
    packageConfig.setParent(null);
    packageConfig.setEntity(genQo.getProjectPackage() + ".modular.system.model");
    packageConfig.setMapper(genQo.getProjectPackage() + ".modular.system.dao");
    packageConfig.setXml(genQo.getProjectPackage() + ".modular.system.dao.mapping");

    /**
     * 业务代码配置
     */
    contextConfig.setBizChName(genQo.getBizName());
    contextConfig.setModuleName(genQo.getModuleName());
    contextConfig.setProjectPath(genQo.getProjectPath());//写自己项目的绝对路径
    if(ToolUtil.isEmpty(genQo.getIgnoreTabelPrefix())){
        String entityName = StrKit.toCamelCase(genQo.getTableName());
        contextConfig.setEntityName(StrKit.firstCharToUpperCase(entityName));
        contextConfig.setBizEnName(StrKit.firstCharToLowerCase(entityName));
    }else{
        String entiyName = StrKit.toCamelCase(StrKit.removePrefix(genQo.getTableName(), genQo.getIgnoreTabelPrefix()));
        contextConfig.setEntityName(StrKit.firstCharToUpperCase(entiyName));
        contextConfig.setBizEnName(StrKit.firstCharToLowerCase(entiyName));
    }
    sqlConfig.setParentMenuName(genQo.getParentMenuName());//这里写已有菜单的名称,当做父节点

    /**
     * mybatis-plus 生成器开关
     */
    contextConfig.setEntitySwitch(genQo.getEntitySwitch());
    contextConfig.setDaoSwitch(genQo.getDaoSwitch());
    contextConfig.setServiceSwitch(genQo.getServiceSwitch());

    /**
     * guns 生成器开关
     */
    contextConfig.setControllerSwitch(genQo.getControllerSwitch());
    contextConfig.setIndexPageSwitch(genQo.getIndexPageSwitch());
    contextConfig.setAddPageSwitch(genQo.getAddPageSwitch());
    contextConfig.setEditPageSwitch(genQo.getEditPageSwitch());
    contextConfig.setJsSwitch(genQo.getJsSwitch());
    contextConfig.setInfoJsSwitch(genQo.getInfoJsSwitch());
    contextConfig.setSqlSwitch(genQo.getSqlSwitch());
}
 
Example #26
Source File: GunsGeneratorConfig.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
protected void strategyConfig() {
    strategyConfig.setTablePrefix(new String[]{"sys_"});// 此处可以修改为您的表前缀
    strategyConfig.setNaming(NamingStrategy.underline_to_camel);
}
 
Example #27
Source File: EntityGenerator.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Test
public void entityGenerator() {
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("F:\\workSpace\\meeting_workspace\\meeting_film\\meeting_film_backend\\guns\\guns-order\\src\\main\\java");//这里写你自己的java目录
    gc.setFileOverride(true);//是否覆盖
    gc.setActiveRecord(true);
    gc.setEnableCache(false);// XML 二级缓存
    gc.setBaseResultMap(true);// XML ResultMap
    gc.setBaseColumnList(false);// XML columList
    gc.setAuthor("jiangzh");
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setTypeConvert(new MySqlTypeConvert() {
        // 自定义数据库表字段类型转换【可选】
        @Override
        public DbColumnType processTypeConvert(String fieldType) {
            return super.processTypeConvert(fieldType);
        }
    });
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
    mpg.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    strategy.setInclude(new String[]{"mooc_order_2017_t","mooc_order_2018_t"});
    mpg.setStrategy(strategy);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent(null);
    pc.setEntity("com.stylefeng.guns.rest.common.persistence.model");
    pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao");
    pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping");
    pc.setService("TTT");       //本项目没用,生成之后删掉
    pc.setServiceImpl("TTT");   //本项目没用,生成之后删掉
    pc.setController("TTT");    //本项目没用,生成之后删掉
    mpg.setPackageInfo(pc);

    // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            Map<String, Object> map = new HashMap<>();
            map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
            this.setMap(map);
        }
    };
    mpg.setCfg(cfg);

    // 执行生成
    mpg.execute();

    // 打印注入设置
    System.err.println(mpg.getCfg().getMap().get("abc"));
}
 
Example #28
Source File: MyBatisPlusGenerator.java    From SpringBootLearn with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    // 代码生成器
    AutoGenerator mpg = new AutoGenerator();

    //1. 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("/Volumes/李浩东的移动硬盘/LiHaodong/springboot-security/src/main/java");
    gc.setOpen(false);
    gc.setFileOverride(true);
    gc.setBaseResultMap(true);//生成基本的resultMap
    gc.setBaseColumnList(false);//生成基本的SQL片段
    gc.setAuthor("lihaodong");// 作者
    mpg.setGlobalConfig(gc);

    //2. 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("root");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/test");
    mpg.setDataSource(dsc);

    //3. 策略配置globalConfiguration中
    StrategyConfig strategy = new StrategyConfig();
    strategy.setTablePrefix("");// 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    strategy.setSuperEntityClass("com.li.springbootsecurity.model");
    strategy.setInclude("role"); // 需要生成的表
    strategy.setEntityLombokModel(true);
    strategy.setRestControllerStyle(true);
    strategy.setControllerMappingHyphenStyle(true);

    mpg.setStrategy(strategy);

    //4. 包名策略配置
    PackageConfig pc = new PackageConfig();
    pc.setParent("com.li.springbootsecurity");
    pc.setEntity("model");
    mpg.setPackageInfo(pc);

    // 执行生成
    mpg.execute();

}
 
Example #29
Source File: EntityGenerator.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Test
public void entityGenerator() {
    AutoGenerator mpg = new AutoGenerator();

    // 全局配置
    GlobalConfig gc = new GlobalConfig();
    gc.setOutputDir("D:\\tmp\\guns\\guns-rest\\src\\main\\java");//这里写你自己的java目录
    gc.setFileOverride(true);//是否覆盖
    gc.setActiveRecord(true);
    gc.setEnableCache(false);// XML 二级缓存
    gc.setBaseResultMap(true);// XML ResultMap
    gc.setBaseColumnList(false);// XML columList
    gc.setAuthor("stylefeng");
    mpg.setGlobalConfig(gc);

    // 数据源配置
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setDbType(DbType.MYSQL);
    dsc.setTypeConvert(new MySqlTypeConvert() {
        // 自定义数据库表字段类型转换【可选】
        @Override
        public DbColumnType processTypeConvert(String fieldType) {
            return super.processTypeConvert(fieldType);
        }
    });
    dsc.setDriverName("com.mysql.jdbc.Driver");
    dsc.setUsername("root");
    dsc.setPassword("root");
    dsc.setUrl("jdbc:mysql://127.0.0.1:3306/rest?characterEncoding=utf8");
    mpg.setDataSource(dsc);

    // 策略配置
    StrategyConfig strategy = new StrategyConfig();
    //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
    strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
    strategy.setInclude(new String[]{"user"});
    mpg.setStrategy(strategy);

    // 包配置
    PackageConfig pc = new PackageConfig();
    pc.setParent(null);
    pc.setEntity("com.stylefeng.guns.rest.persistence.model");
    pc.setMapper("com.stylefeng.guns.rest.persistence.dao");
    pc.setXml("com.stylefeng.guns.rest.persistence.dao.mapping");
    pc.setService("TTT");       //本项目没用,生成之后删掉
    pc.setServiceImpl("TTT");   //本项目没用,生成之后删掉
    pc.setController("TTT");    //本项目没用,生成之后删掉
    mpg.setPackageInfo(pc);

    // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
    InjectionConfig cfg = new InjectionConfig() {
        @Override
        public void initMap() {
            Map<String, Object> map = new HashMap<>();
            map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
            this.setMap(map);
        }
    };
    mpg.setCfg(cfg);

    // 执行生成
    mpg.execute();

    // 打印注入设置
    System.err.println(mpg.getCfg().getMap().get("abc"));
}
 
Example #30
Source File: EntityGenerator.java    From MeetingFilm with Apache License 2.0 4 votes vote down vote up
@Test
    public void entityGenerator() {
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        gc.setOutputDir("G:\\BaiduNetdiskDownload\\应用Dubbo框架打造仿猫眼项目\\MeetingFilm\\guns-cinema\\src\\main\\java");//这里写你自己的java目录
        gc.setFileOverride(true);//是否覆盖
        gc.setActiveRecord(true);
        gc.setEnableCache(false);// XML 二级缓存
        gc.setBaseResultMap(true);// XML ResultMap
        gc.setBaseColumnList(false);// XML columList
        gc.setAuthor("jiangzh");
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setDbType(DbType.MYSQL);
        dsc.setTypeConvert(new MySqlTypeConvert() {
            // 自定义数据库表字段类型转换【可选】
            @Override
            public DbColumnType processTypeConvert(String fieldType) {
                return super.processTypeConvert(fieldType);
            }
        });
        dsc.setDriverName("com.mysql.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("123456789qwER#");
        dsc.setUrl("jdbc:mysql://119.3.214.253:3306/guns_rest?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
        mpg.setDataSource(dsc);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
        strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
//        strategy.setInclude(new String[]{"mooc_banner_t","mooc_cat_dict_t","mooc_area_dict_t","mooc_year_dict_t","mooc_film_t","mooc_film_info_t","mooc_actor_t"});
//        strategy.setInclude(new String[]{"mooc_source_dict_t"});
        strategy.setInclude(new String[]{"mooc_hall_film_info_t"});
        mpg.setStrategy(strategy);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setParent(null);
        pc.setEntity("com.stylefeng.guns.rest.common.persistence.model");
        pc.setMapper("com.stylefeng.guns.rest.common.persistence.dao");
        pc.setXml("com.stylefeng.guns.rest.common.persistence.dao.mapping");
        pc.setService("TTT");       //本项目没用,生成之后删掉
        pc.setServiceImpl("TTT");   //本项目没用,生成之后删掉
        pc.setController("TTT");    //本项目没用,生成之后删掉
        mpg.setPackageInfo(pc);

        // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                Map<String, Object> map = new HashMap<>();
                map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
                this.setMap(map);
            }
        };
        mpg.setCfg(cfg);

        // 执行生成
        mpg.execute();

        // 打印注入设置
        System.err.println(mpg.getCfg().getMap().get("abc"));
    }