您的位置:首页 > 其它

mybatis-generator-core使用

2017-02-09 16:05 295 查看
网上可自行下载相关jar



lib路径中文件如上图

generatorConfig.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>
<!-- 数据库驱动-->
<classPathEntry location="mysql-connector-java-5.1.25-bin.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否要去掉自动生成的注释 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库相关信息-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/test" userId="root" password="123456">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成bean类(实体类)的包名以及路径-->
<javaModelGenerator targetPackage="com.lin.bean" targetProject="src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件(Mapper.xml)的包名以及路径-->
<sqlMapGenerator targetPackage="com.lin.mapping" targetProject="src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成Dao的包名以及路径-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.lin.Dao" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 根据tableName来生成对应的文件 domainObjectName为生成后的实体类名-->
<table tableName="img" domainObjectName="Img" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>

在上述目录下输入以下cmd命令:

java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite



在当前src目录中生成我们所需文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: