1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| AutoGenerator autoGenerator = new AutoGenerator(); GlobalConfig globalConfig= new GlobalConfig(); String path= System.getProperty("user.dir"); System.out.println(path); globalConfig.setFileOverride(false); globalConfig.setActiveRecord(true); globalConfig.setEnableCache(false); globalConfig.setBaseResultMap(true); globalConfig.setBaseColumnList(true); globalConfig.setOutputDir(path+"/src"); globalConfig.setIdType(IdType.AUTO);
DataSourceConfig dataSourceConfig = new DataSourceConfig(); dataSourceConfig.setUrl("jdbc:mysql://localhost:3306/tingyu?useSSL=false&userUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2D8"); dataSourceConfig.setUsername("root"); dataSourceConfig.setPassword("root"); dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
PackageConfig packageConfig = new PackageConfig(); packageConfig.setParent("com") .setMapper("mapper") .setService("service") .setController("controller") .setEntity("entity") .setXml("mapper");
StrategyConfig strategyConfig = new StrategyConfig(); strategyConfig.setCapitalMode(true) .setNaming(NamingStrategy.underline_to_camel) .setTablePrefix("t_") .setInclude("t_admin","t_admin_role","t_company", "t_host","t_host_power","t_married_person", "t_menu","t_order","t_planner","t_role","t_role_menu");
autoGenerator.setGlobalConfig(globalConfig); autoGenerator.setDataSource(dataSourceConfig); autoGenerator.setPackageInfo(packageConfig); autoGenerator.setStrategy(strategyConfig);
autoGenerator.execute(); }
|