zoukankan      html  css  js  c++  java
  • 利用mybatis generator 自动创建代码

    1.下载mybatis-generator-core-1.3.5

      https://github.com/mybatis/generator/releases

    2.解压并进入lib目录

    3.下载mysql-connector-java-5.1.40-bin、mybatis-3.4.4至lib目录

    4.新建src目录和generatorConfig.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   
     6 <generatorConfiguration>    
     7 <!-- 数据库驱动-->    
     8     <classPathEntry  location="mysql-connector-java-5.1.40-bin.jar"/>    
     9     <context id="DB2Tables"  targetRuntime="MyBatis3">    
    10         <commentGenerator>    
    11             <property name="suppressDate" value="true"/>    
    12             <!-- 是否去除自动生成的注释 true:是 : false:否 -->    
    13             <property name="suppressAllComments" value="true"/>    
    14         </commentGenerator>    
    15         <!--数据库链接URL,用户名、密码 -->    
    16         <jdbcConnection 
    17             driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/nutchTest?useSSL=false" userId="root" password="****">    
    18         </jdbcConnection>    
    19         <javaTypeResolver>    
    20             <property name="forceBigDecimals" value="false"/>    
    21         </javaTypeResolver>    
    22         <!-- 生成模型的包名和位置-->    
    23         <javaModelGenerator targetPackage="test.domain" targetProject="src">    
    24             <property name="enableSubPackages" value="true"/>    
    25             <property name="trimStrings" value="true"/>    
    26         </javaModelGenerator>    
    27         <!-- 生成映射文件的包名和位置-->    
    28         <sqlMapGenerator targetPackage="test.mapping" targetProject="src">    
    29             <property name="enableSubPackages" value="true"/>    
    30         </sqlMapGenerator>    
    31         <!-- 生成DAO的包名和位置-->    
    32         <javaClientGenerator type="XMLMAPPER" targetPackage="test.IDao" targetProject="src">    
    33             <property name="enableSubPackages" value="true"/>    
    34         </javaClientGenerator>    
    35         <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->    
    36         <table tableName="crawl_data" domainObjectName="News" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    37     </context>    
    38 </generatorConfiguration>    

    6.命令行下运行;

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

  • 相关阅读:
    一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
    table设置表格有滚动条
    Bootstrap data-toggle 元素 终止了链接默认行为,加入pill ,开启链接
    table的border-radius
    HTML之电话: 邮箱: 网址
    MySQL精华笔记
    hadoop集群配置全过程
    H5 input默认数字键盘,显示为密码格式
    ios中文模糊搜索兼容问题
    Yii2学习笔记---内附GridView配置总结
  • 原文地址:https://www.cnblogs.com/lix-y/p/7607714.html
Copyright © 2011-2022 走看看