一款好用的Mybatis自动生成文件工具

用了好几年,确实好用,今天写个文档mark一下,以免下次又找不到了。

文件下载地址:

简单三步,轻轻松松生成文件:

1. 把plugins中的所有jar拷贝到eclipse的plugins文件夹之中
2. 把features中的所有文件夹拷贝到eclipse的features文件夹之中
3. 重启eclipse,ok

附上generator.xml的文件内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
<!-- 指定mysql的驱动包的路径(禁止放在有中文的目录下) -->
<classPathEntry
location="D://maven//maven-dependcies//m2//repository//mysql//mysql-connector-java//5.1.46//mysql-connector-java-5.1.46.jar" />

<!-- 配置数据源和生成代码所存放的位置 -->
<context id="cont" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 抑制警告 -->
<property name="suppressTypeWarnings" value="true" />
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
<!-- 是否生成注释代时间戳 -->
<property name="suppressDate" value="true" />
</commentGenerator>

<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="数据库地址"
userId="用户名" password="密码" />
<!-- 所生成实体类的位置默认的资源包 -->
<javaModelGenerator
targetPackage="com.demo.model"
targetProject="Demo">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>

<!-- 所生成的sqlmap的映射文件的位置,默认资源包src -->
<sqlMapGenerator
targetPackage="com.demo.mapper"
targetProject="Demo">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>

<javaClientGenerator type="XMLMAPPER"
targetPackage="com..mapper" targetProject="merchant-open-api">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<!-- 为哪些表生成映射文件 tableName:表名 schema:写空即可 -->
<table schema="" tableName="表名" enableCountByExample="false"
domainObjectName="User" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
</table>

</context>
</generatorConfiguration>

配置好,右键项目名称:

猜你喜欢

转载自www.cnblogs.com/lucky-girl/p/10606346.html