- 通用的新增方法
- 通用的分页方法
- 通用的修改方法
- 需要修改的位置
- 项目路径
- jdbcConnection 连接的相关配置
- 生成对应表及类名 这个配置需要修改,你需要对哪些表生产代码就添加哪些表
直接运行GeneratorStartUp类即可
api包主要提供外部接口,供扩展使用,切入点可以试MyPluginAdapter类codegen包是生成文件的核心包,入口是IntrospectedTableMyBatis3Impl类,生成对应文件文件需要的类在对应的 子包中,如:生成xml文件相关的类在xmlmapper包中。internal包下DefaultCommentGenerator类是用于生成对应的文档注释。可以扩展,扩展之后再修改一下generatorConfig.xml
<commentGenerator type="com.jay.generator.internal.MyCommentGenerator">
<property name="javaFileEncoding" value="UTF-8"/>
<!--<property name="suppressDate" value="false"/> <!– 是否生成注释代时间戳 –>-->
<!--<property name="suppressAllComments" value="true"/> <!– 是否取消注释 –>-->
</commentGenerator>
1.适配器模式
MyIntrospectedTableMyBatis3SimpleImpl继承自IntrospectedTableMyBatis3Impl实现了IntrospectedTable接口 该IntrospectedTableMyBatis3Impl类是生成Dao,model,xml文件的主控制类- 扩展方法的话只需要修改
MySimpleXMLMapperGenerator类的getSqlMapElement方法,以及修改MySimpleJavaClientGenerator类的getCompilationUnits方法。在这儿添加你需要添加或者修改的方法。 - 类
MyPluginAdapter允许我们做一些额外的设置,如不需要某些方法生成 - 类
AutoGenerationJavaCodeUpgrade主要生成为了生成service,controller文件,采用ftl变量替换预先定义的方法