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

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

文件下载地址:mysql

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

1. 把plugins中的全部jar拷贝到eclipse的plugins文件夹之中
2. 把features中的全部文件夹拷贝到eclipse的features文件夹之中
3. 重启eclipse,ok数据库

附上generator.xml的文件内容:api

<?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">mybatis

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

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

<!--数据库链接的信息:驱动类、链接地址、用户名、密码 -->
<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>eclipse

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

<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>

配置好,右键项目名称:

 

相关文章
相关标签/搜索