use of com.baomidou.mybatisplus.generator.config.StrategyConfig in project Spring-Cloud by zhao-staff-officer.
the class CodeGeneral method main.
public static void main(String[] args) {
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(Output_Dir);
gc.setAuthor(Author);
// 是否打开输出目录
gc.setOpen(true);
// 覆盖输出
gc.setFileOverride(true);
// Entity名称
gc.setEntityName("%sEntity");
// Dao名称
gc.setMapperName("%sDao");
// Mapper名称
gc.setXmlName("%sMapper");
// XML 二级缓存
gc.setEnableCache(false);
// XML ResultMap
gc.setBaseResultMap(true);
// XML columList
gc.setBaseColumnList(true);
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl(Url);
dsc.setDriverName(Driver_Name);
dsc.setUsername(User_Name);
dsc.setPassword(Pass_Word);
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setController(controller);
pc.setService(service);
pc.setServiceImpl(serviceImpl);
pc.setEntity(Entity);
pc.setMapper(Dao);
mpg.setPackageInfo(pc);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setInclude(tables);
strategy.setControllerMappingHyphenStyle(true);
strategy.setTablePrefix(pc.getModuleName() + "_");
mpg.setStrategy(strategy);
mpg.execute();
}
use of com.baomidou.mybatisplus.generator.config.StrategyConfig in project best-practices by Hansiyuan131.
the class CodeGeneratorTest method generatorCode.
@Test
public void generatorCode() {
// 1、全局配置
GlobalConfig config = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
// 开启AR模式
config.setActiveRecord(true).setAuthor("hansiyuan").setOutputDir(projectPath + "/src/main/java").setFileOverride(true).setOpen(true).setServiceName("%sService").setBaseResultMap(true).setBaseColumnList(true);
// 2、数据源配置
DataSourceConfig dataSourceConfig = new DataSourceConfig();
// 数据库类型
dataSourceConfig.setDbType(DbType.MYSQL).setDriverName("com.mysql.cj.jdbc.Driver").setUrl("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false").setUsername("root").setPassword("mysql123456");
// 3、策略配置
StrategyConfig strategyConfig = new StrategyConfig();
// 开启全局大写命名
strategyConfig.setCapitalMode(true).setNaming(NamingStrategy.underline_to_camel).setColumnNaming(NamingStrategy.underline_to_camel).setRestControllerStyle(true).setEntityLombokModel(true).setInclude("user");
// 4、包名策略配置
PackageConfig packageConfig = new PackageConfig();
// 设置包名的parent
packageConfig.setParent("com.bp.scaffolding").setMapper("mapper").setService("service").setController("api").setEntity("domain.model").setXml("mapper");
// 5、整合配置
AutoGenerator autoGenerator = new AutoGenerator();
autoGenerator.setGlobalConfig(config).setDataSource(dataSourceConfig).setStrategy(strategyConfig).setPackageInfo(packageConfig);
// 6、执行
autoGenerator.execute();
}
use of com.baomidou.mybatisplus.generator.config.StrategyConfig in project scaleph by flowerfine.
the class MybatisPlusGenerator method strategyConfig.
/**
* 策略配置
*
* @return StrategyConfig
*/
private static StrategyConfig strategyConfig() {
StrategyConfig strategy = new StrategyConfig();
strategy.setTablePrefix(TABLE_PREFIX);
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setSuperEntityClass(BaseDO.class);
strategy.setEntityLombokModel(true);
strategy.setSuperEntityColumns(new String[] { "id", "creator", "create_time", "editor", "update_time" });
strategy.setInclude(TABLES);
strategy.setControllerMappingHyphenStyle(true);
strategy.setRestControllerStyle(true);
strategy.setEntityBooleanColumnRemoveIsPrefix(true);
return strategy;
}
use of com.baomidou.mybatisplus.generator.config.StrategyConfig in project coding-more by itwanger.
the class CodeGenerator method main.
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir("d:/test" + "/src/main/java");
gc.setAuthor("石磊");
gc.setOpen(false);
gc.setDateType(DateType.ONLY_DATE);
gc.setSwagger2(true);
gc.setIdType(IdType.AUTO);
gc.setBaseColumnList(true);
gc.setBaseResultMap(true);
gc.setFileOverride(true);
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl("jdbc:mysql://118.190.99.232:3306/codingmoretiny02?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai");
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUsername("codingmoretiny02");
dsc.setPassword("Xw5y8bGFzb86DyGy");
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent("com.codingmore");
mpg.setPackageInfo(pc);
pc.setEntity("model");
// 策略配置,去掉就是生成全部,留下就是生成专属表的
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
strategy.setEntityLombokModel(true);
strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
strategy.setControllerMappingHyphenStyle(true);
mpg.setStrategy(strategy);
mpg.execute();
}
use of com.baomidou.mybatisplus.generator.config.StrategyConfig in project chao-cloud by chaojunzi.
the class MybatisGeneratorConfig method strategyConfig.
@Bean
@ConfigurationProperties(prefix = STRATEGY_CONFIG_PREFIX)
public StrategyConfig strategyConfig() {
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setEntityLombokModel(true);
strategy.setEntityBuilderModel(true);
// strategy.setEntityColumnConstant(true);
// strategy.setEntityTableFieldAnnotationEnable(true);
// strategy.setSuperEntityClass("com.baomidou.ant.common.BaseEntity");
// strategy.setSuperEntityColumns("id");
// strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
// strategy.setRestControllerStyle(true);
strategy.setControllerMappingHyphenStyle(true);
strategy.setVersionFieldName("version");
return strategy;
}
Aggregations