zoukankan      html  css  js  c++  java
  • SpringMVC+Spring+Mybatis+Generator工具

    • Generator工作空间准备

    • 配置文件(generator.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="E:generatormysql-connector-java-5.1.10-bin.jar" />
        <!--classPathEntry location="C:oracleproduct10.2.0db_1jdbclibojdbc14.jar" /-->
        <context id="DB2Tables" targetRuntime="MyBatis3">
            <commentGenerator>
                <property name="suppressAllComments" value="true" />
            </commentGenerator>
            <!-- 数据库链接URL、用户名、密码 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/uracsdb" userId="root" password="root"/>
            <!--jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" userId="msa" password="msa">
            </jdbcConnection-->
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
            <!-- 生成模型的包名和位置 -->
            <javaModelGenerator targetPackage="bling.model" targetProject="E:generatorsrc">
                <property name="enableSubPackages" value="true" />
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
            <!-- 生成的映射文件包名和位置 -->
            <sqlMapGenerator targetPackage="bling.mapping" targetProject="E:generatorsrc">
                <property name="enableSubPackages" value="true" />
            </sqlMapGenerator>
            <!-- 生成DAO的包名和位置 -->
            <javaClientGenerator type="XMLMAPPER" targetPackage="bling.dao" targetProject="E:generatorsrc">
                <property name="enableSubPackages" value="true" />
            </javaClientGenerator>
            <!-- 要生成那些表(更改tableName和domainObjectName就可以) -->
            <table tableName="t_app_user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
            <table tableName="t_app_menu" domainObjectName="Menu" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
            <table tableName="t_app_role_menu" domainObjectName="RoleMenu" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
            <table tableName="t_app_role" domainObjectName="Role" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
            <table tableName="t_app_user_role" domainObjectName="UserRole" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
        </context>
    </generatorConfiguration>
    • 生成语句

      到generator文件夹下,按住shift+鼠标右键点击“在此处打开命令窗口(win7)”,输入以下命令即可在src中生成需要的代码:dao、mapping、model

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

  • 相关阅读:
    HBase Flush 机制
    HBase 预分区 & Phoenix 加盐
    Phoenix 索引
    python 列表、元组、字典、集合的比较操作
    Redis HA
    基于 Redis 和 ZooKeeper 的分布式锁
    Ubuntu 系统设置 Swappiness 值
    Ubuntu_16.04 安装 Pyhon3.6
    Win10创意者更新秋季版升级常见问题解决方案
    如何使用注册表在Win10中调整屏幕亮度
  • 原文地址:https://www.cnblogs.com/yangml/p/3835034.html
Copyright © 2011-2022 走看看