271 | * 读取控制台内容 272 | *
273 | */ 274 | public static String scanner(String tip) { 275 | Scanner scanner = new Scanner(System.in); 276 | StringBuilder help = new StringBuilder(); 277 | help.append("请输入" + tip + ":"); 278 | System.out.println(help.toString()); 279 | if (scanner.hasNext()) { 280 | String ipt = scanner.next(); 281 | if (StringUtils.isNotBlank(ipt)) { 282 | return ipt; 283 | } 284 | } 285 | throw new MybatisPlusException("请输入正确的" + tip + "!"); 286 | } 287 | 288 | public static void main(String[] args) { 289 | // 代码生成器 290 | AutoGenerator mpg = new AutoGenerator(); 291 | 292 | // 全局配置 293 | GlobalConfig gc = new GlobalConfig(); 294 | String projectPath = System.getProperty("user.dir"); 295 | gc.setOutputDir(projectPath + "/src/main/java"); 296 | gc.setAuthor("linsuwen"); 297 | gc.setOpen(false); 298 | gc.setSwagger2(true); //实体属性 Swagger2 注解 299 | gc.setBaseResultMap(true); // XML ResultMap 300 | gc.setBaseColumnList(true); // XML columList 301 | //去掉service接口首字母的I, 如DO为User则叫UserService 302 | gc.setServiceName("%sService"); 303 | mpg.setGlobalConfig(gc); 304 | 305 | // 数据源配置 306 | DataSourceConfig dsc = new DataSourceConfig(); 307 | dsc.setUrl("jdbc:mysql://localhost:3306/wms?useUnicode=true&characterEncoding=utf-8&serveTimezone=UTC"); 308 | // dsc.setSchemaName("public"); 309 | dsc.setDriverName("com.mysql.cj.jdbc.Driver"); 310 | dsc.setUsername("root"); 311 | dsc.setPassword("123456"); 312 | mpg.setDataSource(dsc); 313 | 314 | // 包配置 315 | PackageConfig pc = new PackageConfig(); 316 | //pc.setModuleName(scanner("模块名")); 317 | //模块配置 318 | pc.setParent("com.wms") 319 | .setEntity("entity") 320 | .setMapper("mapper") 321 | .setService("service") 322 | .setServiceImpl("service.Impl") 323 | .setController("controller"); 324 | mpg.setPackageInfo(pc); 325 | 326 | // 自定义配置 327 | InjectionConfig cfg = new InjectionConfig() { 328 | @Override 329 | public void initMap() { 330 | // to do nothing 331 | } 332 | }; 333 | 334 | // 如果模板引擎是 freemarker 335 | String templatePath = "/templates/mapper.xml.ftl"; 336 | // 如果模板引擎是 velocity 337 | // String templatePath = "/templates/mapper.xml.vm"; 338 | 339 | // 自定义输出配置 340 | List