目录结构
资源地址
https://pan.baidu.com/s/1vz2DRUlWH7tscIRd5R9wmg
配置文件(以generatorConfig_student.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>
<!-- 本地数据库jdbc驱动包路径,为目录结构中的mysql-connector-java-5.1.46.jar-->
<classPathEntry location="E:\mybatisgenerator\mysql-connector-java-5.1.46.jar" />
<context id="MysqlTables" targetRuntime="MyBatis3">
<property name="mergeable" value="true"/>
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!-- jdbc数据库连接配置 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/student"
userId="root"
password="123456"></jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetPackage为本地实体类项目相对路径 targetProject为项目包绝对路径-->
<!--pojo-->
<javaModelGenerator targetPackage="com.thy.student.pojo" targetProject="E:\mybatisgenerator\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!--xml-->
<sqlMapGenerator targetPackage="com.thy.student.mapper" targetProject="E:\mybatisgenerator\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!--mapper-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.thy.student.dao" targetProject="E:\mybatisgenerator\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!--tableName为表名,domainObjectName为实体类名-->
<table schema="" tableName="t_fastdfs_file" domainObjectName="FastdfsFile">
</table>
</context>
</generatorConfiguration>
以上有注释的地方根据自己的需要进行修改
执行方法
打开cmd命令行,进入该目录路径,输入以下命令回车执行
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig_student.xml
执行结果
在目录中的src下生成了相应的文件
网友评论