• 开发环境搭建之springboot+tk.mybatis整合使用逆向工程


    一,引入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>
        <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
            <property name="javaFileEncoding" value="UTF-8"/>
            <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
                <property name="mappers" value="com.example.ordersystem.common.mapper.SchoolBaseMapper"/>
            </plugin>
            <!-- 生成注释配置 -->
            <commentGenerator>
                <!-- 是否取消注释 -->
                <property name="suppressAllComments" value="false"/>
                <!-- 数据库注释支持 -->
                <property name="addRemarkComments" value="false"/>
                <!-- 时间格式设置 -->
                <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"/>
            </commentGenerator>
    
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                            connectionURL="jdbc:mysql://ip地址:3306/order_system?serverTimezone=GMT%2B8"
                            userId="root"
                            password="root">
            </jdbcConnection>
    
            <javaModelGenerator targetPackage="com.example.ordersystem.common.entity" targetProject="src/main/java"/>
    
            <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"/>
    
            <javaClientGenerator targetPackage="com.example.ordersystem.common.mapper"
                                 targetProject="src/main/java" type="XMLMAPPER"/>
    
            <!--       <table tableName="t%" >
                       <generatedKey column="id" sqlStatement="MySql" identity="true" />
                       <domainObjectRenamingRule searchString="^T" replaceString="" />
                       <columnRenamingRule searchString="^T" replaceString=""/>
                   </table>-->
            <table tableName="order_detail">
                <generatedKey column="detail_id" sqlStatement="MySql" identity="true"/>
                <domainObjectRenamingRule searchString="^T" replaceString=""/>
                <columnRenamingRule searchString="^T" replaceString=""/>
            </table>
            <table tableName="order_master">
                <generatedKey column="order_id" sqlStatement="MySql" identity="true"/>
                <domainObjectRenamingRule searchString="^T" replaceString=""/>
                <columnRenamingRule searchString="^T" replaceString=""/>
            </table>
            <table tableName="product_category">
                <generatedKey column="category_id" sqlStatement="MySql" identity="true"/>
                <domainObjectRenamingRule searchString="^T" replaceString=""/>
                <columnRenamingRule searchString="^T" replaceString=""/>
            </table>
            <table tableName="product_info">
                <generatedKey column="product_id" sqlStatement="MySql" identity="true"/>
                <domainObjectRenamingRule searchString="^T" replaceString=""/>
                <columnRenamingRule searchString="^T" replaceString=""/>
            </table>
        </context>
    </generatorConfiguration>

    这个配置文件中可以去除添加去除创建的T

    在pom文件中引入插件:

    <plugin>
                    <groupId>org.mybatis.generator</groupId>
                    <artifactId>mybatis-generator-maven-plugin</artifactId>
                    <version> 1.36</version>
                    <configuration>
                        <configurationFile>${basedir}/src/main/resources/generator/generatorConfiglocal.xml
                        </configurationFile>
                        <overwrite>true</overwrite>
                        <verbose>true</verbose>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>runtime</version>
                        </dependency>
                        <dependency>
                            <groupId>tk.mybatis</groupId>
                            <artifactId>mapper</artifactId>
                            <version>3.4.6</version>
                        </dependency>
                    </dependencies>
                </plugin>

    然后再使用maven上个的插件,就可以直接生成dao,mapper,mapper.xml文件

  • 相关阅读:
    【转】Wrapper配置详解及高级应用
    【转】Eclipse4.4.1安装velocity插件Veloeclipse.ui_2.0.8
    【转】创建SVN仓库的步骤
    【转】Hibernate 常见异常
    [转]Java中Map的用法详解
    [转]CocoaPods安装和使用教程
    [转]struts1.2的action参数配置
    [转]hibernateTools工具安装及使用总结(eclipse 3.6)
    [转]iOS开发中@property的属性weak nonatomic strong readonly等介绍
    [转]使用 Xcode 5 和 Interface Builder创建 Hello World App
  • 原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11607468.html
Copyright © 2020-2023  润新知