自动生成mybaist配置文件

来源:互联网 发布:ubuntu安装硬盘分区 编辑:程序博客网 时间:2024/06/05 23:39

mybatis-generator-core-1.3.2.jar

mysql-connector-java-5.1.30.jar

generatorConfig.xml


要自动生成mybaist 配置文件,第一步,需要一个mybatiis的核心包和一个mysql 的链接包。第二步需要一个配置链接的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.30.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://10.202.37.123:3306/ccsporder" userId="order" password="sf123456">
 


         </jdbcConnection>

 
         <javaTypeResolver>
             <property name="forceBigDecimals" value="false"/>
         </javaTypeResolver>
 
 
   
         <javaModelGenerator targetPackage="com.sf.ccsp.exp.core.dao.domain.waybill" targetProject="src">
             <property name="enableSubPackages" value="true"/>
             <property name="trimStrings" value="true"/>
         </javaModelGenerator>
 
 
         <sqlMapGenerator targetPackage="com.sf.ccsp.exp.core.dao.domain.waybill" targetProject="src">
             <property name="enableSubPackages" value="true"/>
         </sqlMapGenerator>
 


         <javaClientGenerator type="XMLMAPPER" targetPackage="com.sf.ccsp.exp.core.dao.mapper.waybill" targetProject="src">
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
 
 
         
 
<table tableName="cx_appointment_order_customer_address" domainObjectName="xxx" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
 
 
     </context>
 </generatorConfiguration>


保存完这些文件之后,运行cmd命令到该文件夹下。执行cmd命令即可。

cmd命令如下:

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


一般我喜欢我脚本去操作。自己写的bat脚本如下:

@echo off


cd\


e:


cd MybatisGenerator


dir


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


@pause


这样运行bat脚本,即可。


脚本删除生成好的文件夹。自动生成mybatis配置删除脚本



@echo off


rd /s /Q E:\MybatisGenerator\src


md E:\MybatisGenerator\src


@pause


运行删除脚本即可删除生成好的配置文件。


原创粉丝点击