• ssm项目中逆向工程的配置


    一、添加依赖

    <!--逆向工程 -->
            <dependency>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-core</artifactId>
                <version>1.3.5</version>
            </dependency>
    <!--Mysql依赖 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.25</version>
            </dependency>

    二、添加插件

    <!--Mybatis逆向工程插件 -->
                <plugin>
                    <groupId>org.mybatis.generator</groupId>
                    <artifactId>mybatis-generator-maven-plugin</artifactId>
                    <version>1.3.2</version>
                    <dependencies>
                        <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>5.1.35</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <!--配置文件的路径 -->
                        <configurationFile>src/main/resources/generator/generatorConfig.xml</configurationFile>
                        <overwrite>true</overwrite>
                    </configuration>
                </plugin>

    三、准备逆向工程配置文件

    <?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>
        <!-- targetRuntime="MyBatis3Simple"中加Simple为较为简单的代码 -->
        <context id="testTables" targetRuntime="MyBatis3Simple">
            <commentGenerator>
                <!-- 是否去除自动生成的注释 true:是 : false:否 -->
                <property name="suppressAllComments" value="true" />
            </commentGenerator>
            <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                connectionURL="jdbc:mysql://localhost:3306/oline_q_a" userId="root"
                password="ROOT">
            </jdbcConnection>
            <!-- <jdbcConnection driverClass="oracle.jdbc.OracleDriver" connectionURL="jdbc:oracle:thin:@127.0.0.1:1521:yycg" 
                userId="yycg" password="yycg"> </jdbcConnection> -->
    
            <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 
                和 NUMERIC 类型解析为java.math.BigDecimal -->
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false" />
            </javaTypeResolver>
    
            <!-- ***************************************************targetProject:生成PO类的位置 -->
            <javaModelGenerator targetPackage="com.ssm.pojo"
                targetProject="question_and_answer2">
                <!-- enableSubPackages:是否让schema作为包的后缀 -->
                <property name="enableSubPackages" value="false" />
                <!-- 从数据库返回的值被清理前后的空格 -->
                <property name="trimStrings" value="true" />
            </javaModelGenerator>
            <!--******************************************* targetProject:mapper映射文件生成的位置 -->
            <sqlMapGenerator targetPackage="com.ssm.mapper"
                targetProject="question_and_answer2">
                <!-- enableSubPackages:是否让schema作为包的后缀 -->
                <property name="enableSubPackages" value="false" />
            </sqlMapGenerator>
            <!-- **********************************************targetPackage:mapper接口生成的位置 -->
            <javaClientGenerator type="XMLMAPPER"
                targetPackage="com.ssm.mapper" targetProject="question_and_answer2">
                <!-- enableSubPackages:是否让schema作为包的后缀 -->
                <property name="enableSubPackages" value="false" />
            </javaClientGenerator>
            <!-- ********************************************************************指定数据库表 -->
            <table tableName="course" enableCountByExample="false"
                enableUpdateByExample="false" enableDeleteByExample="false"
                enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="notice" enableCountByExample="false"
                enableUpdateByExample="false" enableDeleteByExample="false"
                enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="question" enableCountByExample="false"
                enableUpdateByExample="false" enableDeleteByExample="false"
                enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="reply" enableCountByExample="false"
                enableUpdateByExample="false" enableDeleteByExample="false"
                enableSelectByExample="false" selectByExampleQueryId="false"></table>
            <table tableName="users" enableCountByExample="false"
                enableUpdateByExample="false" enableDeleteByExample="false"
                enableSelectByExample="false" selectByExampleQueryId="false"></table>
        </context>
    </generatorConfiguration>

    四、下载准备,Mybatis Generator插件

    五、运行配置文件,生成pojomappermapper接口

     六、遇到的问题

     

    本文来自博客园,作者:我有一个梦想panghao,转载请注明原文链接:https://www.cnblogs.com/panghao/p/13492564.html

  • 相关阅读:
    php与WebservicesNuSOAP的使用说明(转载)
    获取cpu序列号,硬盘ID,网卡MAC地址(转载)
    system.net.sockets.tcplistener
    用VS2005实现软件多语言版本的迅捷开发(转载)
    洛谷P1776 宝物筛选 题解 多重背包
    2013 ACMICPC亚洲区域赛南京站C题 题解 轮廓线DP
    2017 ACMICPC亚洲区域赛北京站J题 Pangu and Stones 题解 区间DP
    洛谷P1385 密令 题解 动态规划
    洛谷P1028 数的计算 题解 动态规划入门题
    洛谷P1029 最大公约数和最小公倍数问题 题解
  • 原文地址:https://www.cnblogs.com/panghao/p/13492564.html
Copyright © 2020-2023  润新知