generator
generator copied to clipboard
输出自定义模板文件输出路径格式与官网文档的代码不一致
当前使用版本(必填,否则不予处理)
3.5.2
该问题是如何引起的?(确定最新版也有问题再提!!!)
不知道这个是算个bug呢 ,还是由于特殊原因就要要求这样写的。
输出自定义模板文件输出路径格式与官网文档的代码不一致。
现在最新的版本代码输出的路径为 :entityName + File.separator + "%s",这样每次路径下都多出一个 entityName 的文件夹,如图:
源码实现如下:
protected void outputCustomFile(@NotNull Map<String, String> customFile, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) { String entityName = tableInfo.getEntityName(); String otherPath = getPathInfo(OutputFile.other); customFile.forEach((key, value) -> { String fileName = String.format((otherPath + File.separator + entityName + File.separator + "%s"), key); outputFile(new File(fileName), objectMap, value, getConfigBuilder().getInjectionConfig().isFileOverride()); }); }
重现步骤(如果有就写完整)
- 自己编写VO模版
- InjectionConfig.Builder 配置自定义模版和输出路径 customFile.put("VO.java", "/templates/entityDTO.java.ftl");
- 生成模版
报错信息
无
@hu582205 hello,新版3.5.3 已发布,已重构了自定义文件生成的逻辑,详情请看
https://github.com/baomidou/generator/commit/3af34e1b036e48c0f5074e88d3b1f2ea9889ceeb
例子: https://github.com/baomidou/generator/blob/develop/mybatis-plus-generator/src/test/java/com/baomidou/mybatisplus/generator/samples/H2CodeGeneratorTest.java#L211