当前使用版本(必须填写清楚,否则不予处理)

3.1.2

该问题是怎么引起的?(最新版上已修复的会直接close掉)

支持例如 entity每次生成进行覆盖,mapper接口或service接口不覆盖吗? 因为 一般对表的改动都是加减字段,自动生成时希望进行覆盖 但是 接口会进行扩展方法,希望每次自动生成时不覆盖。

重现步骤

报错信息

Comment From: qmdx

默认的是否覆盖针对所有生成文件 InjectionConfig 注入 com.baomidou.mybatisplus.generator.config.FileOutConfig 的实现去判断是否要覆盖。

Comment From: yuhangtdm

嗯嗯,我重写了一些方法实现了我的逻辑了

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: qmdx <notifications@github.com> 发送时间: 2019年12月3日 16:02 收件人: baomidou/mybatis-plus <mybatis-plus@noreply.github.com> 抄送: yuhangtdm <649411629@qq.com>, Author <author@noreply.github.com> 主题: 回复:[baomidou/mybatis-plus] 支持指定代码覆盖吗? (#1905)

默认的是否覆盖针对所有生成文件 InjectionConfig 注入 com.baomidou.mybatisplus.generator.config.FileOutConfig 的实现去判断是否要覆盖。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Comment From: chenweibo

@yuhangtdm 兄弟怎么配置的我能看看嘛

Comment From: yuhangtdm

大概的解决方式: 实现AutoGenerator 这个类 重写getAllTableInfoList 方法 config.setInjectionConfig(getInjectionConfig(config)); 方法里重写配置 配置里 根据FileType 判断ENTITY时 为true 即可

        public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
            // 判断自定义文件夹是否需要创建,这里调用默认的方法
            checkDir(filePath);
            //对于已存在的文件,只需重复生成 entity
            File file = new File(filePath);
            boolean exist = file.exists();
            // 自定义的文件不生成
            if (FileType.OTHER == fileType) {
                return false;
            }
            if (exist) {
                if (FileType.ENTITY == fileType) {
                    return true;
                } else {
                    return false;
                }
            }
            //不存在的文件都需要创建
            return true;
        }

可参考我写的 https://github.com/yuhangtdm/dmall/blob/master/dmall-component/dmall-component-dao-mybatisplus/src/main/java/com/dmall/component/mybatisplus/generator/DMallAutoGenerator.java 但是我的这个项目里 加了不少自定义的生成模板的逻辑。。。

------------------ 原始邮件 ------------------ 发件人: "chenweibo"<notifications@github.com>; 发送时间: 2020年1月20日(星期一) 下午3:03 收件人: "baomidou/mybatis-plus"<mybatis-plus@noreply.github.com>; 抄送: "Dity"<649411629@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [baomidou/mybatis-plus] 支持指定代码覆盖吗? (#1905)

@yuhangtdm 兄弟怎么配置的我能看看嘛

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.