Java Code Examples for com.baomidou.mybatisplus.generator.config.GlobalConfig#setServiceName()

The following examples show how to use com.baomidou.mybatisplus.generator.config.GlobalConfig#setServiceName() . 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: 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 2
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 3
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 4
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 5
Source File: CodeGenerator.java    From My-Blog-layui 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 + outPutDir);
        gc.setDateType(DateType.ONLY_DATE);
        gc.setAuthor("zhulin");
        gc.setOpen(false);
        gc.setBaseResultMap(true);
        gc.setBaseColumnList(true);
        // 覆盖生成的文件
        gc.setFileOverride(true);
        gc.setServiceName("%sService");
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl(dataUrl);
        dsc.setDriverName(driverName);
        dsc.setUsername(dataName);
        dsc.setPassword(dataPwd);
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setParent(parentPackage)
                .setMapper(mapperName)
                .setEntity(pojoName)
                .setService(serviceName)
                .setController(controllerName)
                .setServiceImpl(implName)
                .setXml(xmlName);
        mpg.setPackageInfo(pc);

/*        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };
        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        focList.add(new FileOutConfig() {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return projectPath + "/src/main/resources/mapping/"
                        + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);*/


        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        strategy.setEntityTableFieldAnnotationEnable(true);
        strategy.setEntityLombokModel(true);
        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
        //默认生成全部
/*        strategy.setExclude(null);*/
        strategy.setControllerMappingHyphenStyle(true);
        mpg.setStrategy(strategy);
        mpg.execute();
    }
 
Example 6
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();

}