zoukankan      html  css  js  c++  java
  • mybatis自动生成mapping和实体

    首先建立一个非中文的目录,主要包含以下文件

    生成mapping等需要的xml文件,

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!DOCTYPE generatorConfiguration
     3   PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
     4   "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
     5 <generatorConfiguration>
     6     <!--数据库驱动-->
     7     <classPathEntry    location="mysql-connector-java-5.1.38.jar"/>
     8     <context id="DB2Tables"    targetRuntime="MyBatis3">
     9         <commentGenerator>
    10             <property name="suppressDate" value="true"/>
    11             <property name="suppressAllComments" value="true"/>
    12         </commentGenerator>
    13         <!--数据库链接地址账号密码-->
    16         <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test123?characterEncoding=utf8" userId="root" password="root">
    17         </jdbcConnection>
    18         <javaTypeResolver>
    19             <property name="forceBigDecimals" value="false"/>
    20         </javaTypeResolver>
    21         <!--生成Model类存放位置-->
    22         <javaModelGenerator targetPackage="com.flysand.model.entity" targetProject="src">
    23             <property name="enableSubPackages" value="true"/>
    24             <property name="trimStrings" value="true"/>
    25         </javaModelGenerator>
    26         <!--生成映射文件存放位置-->
    27         <sqlMapGenerator targetPackage="mybatis.mappers" targetProject="src">
    28             <property name="enableSubPackages" value="true"/>
    29         </sqlMapGenerator>
    30         <!--生成Dao类存放位置-->
    31         <javaClientGenerator type="XMLMAPPER" targetPackage="com.flysand.dao" targetProject="src">
    32             <property name="enableSubPackages" value="true"/>
    33         </javaClientGenerator>
    34         <!--生成对应表及类名-->
    35        <!-- <table tableName="S_Order" domainObjectName="S_Order" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> -->
    36        <table tableName="T_USER" domainObjectName="TUser" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
    37     </context>
    38 </generatorConfiguration>

    生成语句

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

    可以在当前目录按shift右键,在当前目录打开命令行

  • 相关阅读:
    Spring 源码学习 09:refresh 大概流程
    Spring 源码学习 08:register 注册配置类
    Vmware安装苹果系统(Apple Mac OS X)详细
    React Native利用router-flux简单实现标签页切换
    IntelliJ IDEA 搭建配置Maven(二)
    IntelliJ IDEA 从下载到安装(一)
    SSM框架知识简单整合
    1221条电脑蓝屏代码大全
    ISO刻录U盘重新系统方法
    重装系统(GHO)镜像介绍及下载
  • 原文地址:https://www.cnblogs.com/flysand/p/6650956.html
Copyright © 2011-2022 走看看