com.baomidou.mybatisplus.core.toolkit.StringPool Java Examples
The following examples show how to use
com.baomidou.mybatisplus.core.toolkit.StringPool.
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: JWTFilter.java From permission with MIT License | 6 votes |
/** * 执行登录认证 * * @param request * @param response * @param mappedValue * @return */ @Override protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws UnauthorizedException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String anonUrl = SpringContextUtil.getBean(PermissionProperties.class).getAnonUrl(); String[] anonUrls = anonUrl.split(StringPool.COMMA); boolean match = false; for (String u : anonUrls) { if (pathMatcher.match(u, httpServletRequest.getRequestURI())) match = true; } if (match) { return true; } if (isLoginAttempt(request, response)) { return executeLogin(request, response); } return false; }
Example #2
Source File: Sequence.java From microservices-platform with Apache License 2.0 | 6 votes |
/** * <p> * 获取 maxWorkerId * </p> */ protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { StringBuilder mpid = new StringBuilder(); mpid.append(datacenterId); String name = ManagementFactory.getRuntimeMXBean().getName(); if (StrUtil.isNotEmpty(name)) { /* * GET jvmPid */ mpid.append(name.split(StringPool.AT)[0]); } /* * MAC + PID 的 hashcode 获取16个低位 */ return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); }
Example #3
Source File: UserServiceImpl.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
@Override @Transactional(rollbackFor = Exception.class) public void updateUser(User user) { String username = user.getUsername(); // 更新用户 user.setPassword(null); user.setUsername(null); user.setModifyTime(new Date()); updateById(user); // 更新关联角色 this.userRoleService.remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, user.getUserId())); String[] roles = user.getRoleId().split(StringPool.COMMA); setUserRoles(user, roles); User currentUser = FebsUtil.getCurrentUser(); if (StringUtils.equalsIgnoreCase(currentUser.getUsername(), username)) { shiroRealm.clearCache(); } }
Example #4
Source File: RoleServiceImpl.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
private void saveRoleMenus(Role role) { if (StringUtils.isNotBlank(role.getMenuIds())) { String[] menuIds = role.getMenuIds().split(StringPool.COMMA); List<RoleMenu> roleMenus = new ArrayList<>(); Arrays.stream(menuIds).forEach(menuId -> { RoleMenu roleMenu = new RoleMenu(); roleMenu.setMenuId(Long.valueOf(menuId)); roleMenu.setRoleId(role.getRoleId()); roleMenus.add(roleMenu); }); roleMenuService.saveBatch(roleMenus); } }
Example #5
Source File: CodeGenUtil.java From pre with GNU General Public License v3.0 | 5 votes |
/** * 集成 * * @param dataSourceConfig 配置数据源 * @param strategyConfig 策略配置 * @param config 全局变量配置 * @param packageConfig 包名配置 */ private void atuoGenerator(DataSourceConfig dataSourceConfig, StrategyConfig strategyConfig, GlobalConfig config, PackageConfig packageConfig, String moduleName) { // 自定义配置 InjectionConfig cfg = new InjectionConfig() { @Override public void initMap() { } }; // 自定义输出配置 List<FileOutConfig> focList = new ArrayList<>(); // 模板引擎是 velocity String templatePath = "/templates/mapper.xml.vm"; // 自定义配置会被优先输出 focList.add(new FileOutConfig(templatePath) { @Override public String outputFile(TableInfo tableInfo) { // 自定义输出文件名 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化 return getResourcesOutputDir(moduleName) + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML; } }); cfg.setFileOutConfigList(focList); // 配置模板 TemplateConfig templateConfig = new TemplateConfig(); templateConfig.setXml(null); new AutoGenerator() .setGlobalConfig(config) .setDataSource(dataSourceConfig) .setStrategy(strategyConfig) .setPackageInfo(packageConfig) .setCfg(cfg) .setTemplate(templateConfig) .setTemplateEngine(new VelocityTemplateEngine()) .execute(); }
Example #6
Source File: UserController.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@GetMapping("delete/{userIds}") @RequiresPermissions("user:delete") @ControllerEndpoint(operation = "删除用户", exceptionMessage = "删除用户失败") public DunwuResponse deleteUsers(@NotBlank(message = "{required}") @PathVariable String userIds) { String[] ids = userIds.split(StringPool.COMMA); this.userService.deleteUsers(ids); return new DunwuResponse().success(); }
Example #7
Source File: UserController.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@PostMapping("password/reset/{usernames}") @RequiresPermissions("user:password:reset") @ControllerEndpoint(exceptionMessage = "重置用户密码失败") public DunwuResponse resetPassword(@NotBlank(message = "{required}") @PathVariable String usernames) { String[] usernameArr = usernames.split(StringPool.COMMA); this.userService.resetPassword(usernameArr); return new DunwuResponse().success(); }
Example #8
Source File: DeptController.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@GetMapping("delete/{deptIds}") @RequiresPermissions("dept:delete") @ControllerEndpoint(operation = "删除部门", exceptionMessage = "删除部门失败") public DunwuResponse deleteDepts(@NotBlank(message = "{required}") @PathVariable String deptIds) throws FebsException { String[] ids = deptIds.split(StringPool.COMMA); this.deptService.deleteDepts(ids); return new DunwuResponse().success(); }
Example #9
Source File: MenuServiceImpl.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) public void deleteMeuns(String menuIds) { String[] menuIdsArray = menuIds.split(StringPool.COMMA); this.delete(Arrays.asList(menuIdsArray)); shiroRealm.clearCache(); }
Example #10
Source File: UserServiceImpl.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) public void createUser(User user) { user.setCreateTime(new Date()); user.setStatus(User.STATUS_VALID); user.setAvatar(User.DEFAULT_AVATAR); user.setTheme(User.THEME_BLACK); user.setIsTab(User.TAB_OPEN); user.setPassword(Md5Util.encrypt(user.getUsername(), User.DEFAULT_PASSWORD)); save(user); // 保存用户角色 String[] roles = user.getRoleId().split(StringPool.COMMA); setUserRoles(user, roles); }
Example #11
Source File: RoleServiceImpl.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) public void deleteRoles(String roleIds) { List<String> list = Arrays.asList(roleIds.split(StringPool.COMMA)); this.baseMapper.delete(new QueryWrapper<Role>().lambda().in(Role::getRoleId, list)); this.roleMenuService.deleteRoleMenusByRoleId(list); this.userRoleService.deleteUserRolesByRoleId(list); }
Example #12
Source File: CodeGenerator.java From oauth-boot with MIT License | 4 votes |
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 #13
Source File: CodeGeneratorUtils.java From spring-boot-shiro with Apache License 2.0 | 4 votes |
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 #14
Source File: GeneratorService.java From spring-cloud-shop with MIT License | 4 votes |
/** * 自动生成代码 * * @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: Generator.java From Nickle-Scheduler with Apache License 2.0 | 4 votes |
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 #16
Source File: CodeGenerator2.java From kvf-admin with MIT License | 4 votes |
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 #17
Source File: MysqlGenerator.java From spring-boot-demo with MIT License | 4 votes |
/** * 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(); }