首页 > 学院 > 开发设计 > 正文

mybatis-generator-core使用

2019-11-08 20:45:59
字体:
来源:转载
供稿:网友

网上可自行下载相关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目录中生成我们所需文件。


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表