mybatisGenerator代码生成器

使用mybatisGenerator可以生成实体类,Mapper接口以及对应xml文件。本文介绍如何使用。

可以直接从本人github下载,只需按照如下步骤即可:

  1.导入项目至idea中,项目结构如下:

 将lib中所需jar包添加至项目中:

  点击project structure->Libraries,点击绿色加号,选择Java,选择当前项目下lib包,选择ok即可,点击apply应用

在generatorConfig.xml文件中配置自己的数据库:

进入src目录下,点击GeneratorSqlmap运行即可完成代码的生成。

src目录下comment/MyDefaultCommentGenerator类主要是在生成的pojo类中生成数据库表中的注释

在generatorConfig.xml中的配置为:

<commentGenerator type="comment.MyDefaultCommentGenerator">
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
如果不想生成,直接去掉 type="comment.MyDefaultCommentGenerator"即可。
生成效果如下图所示:


最后附上代码下载地址

猜你喜欢

转载自www.cnblogs.com/tianwamg/p/10662804.html