• 【Mybatis】Mybatis generator的使用


    pom.xml

            <plugin>
                    <groupId>org.mybatis.generator</groupId>
                    <artifactId>mybatis-generator-maven-plugin</artifactId>
                    <version>1.3.2</version>
                    <configuration>
                        <configurationFile>src/main/resources/generator/generatorConfig.xml</configurationFile>
                        <verbose>true</verbose>
                        <overwrite>true</overwrite>
                    </configuration>
                    <executions>
                        <execution>
                            <id>Generate MyBatis Artifacts</id>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.mybatis.generator</groupId>
                            <artifactId>mybatis-generator-core</artifactId>
                            <version>1.3.2</version>
                        </dependency>
                        <dependency>
                            <groupId>tk.mybatis</groupId>
                            <artifactId>mapper</artifactId>
                            <version>3.3.9</version>
                        </dependency>
                    </dependencies>
                </plugin>

    generatorConfig.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:mysql-connector-java-5.1.25.jar"/>-->
        <classPathEntry location="E:ojdbc6.jar"/>
        <!--  location="F:MavenRepositorymysqlmysql-connector-java5.1.37mysql-connector-java-5.1.37.jar"/>-->
        <context id="MysqlContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
    
    
            <property name="beginningDelimiter" value="`"/>
            <property name="endingDelimiter" value="`"/>
            <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
                <property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
            </plugin>
            <!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                             connectionURL="jdbc:mysql://192.168.18.7:3306/hd_ship_cloud?characterEncoding=utf8"
                             userId="root"
                             password="root">
             </jdbcConnection>-->
            <commentGenerator>
                <property name="suppressAllComments" value="false" />
            </commentGenerator>
    
            <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
                            connectionURL="jdbc:oracle:thin:@192.168.18.2:1521:orcl"
                            userId="shiptracker_smart"
                            password="ok">
            </jdbcConnection>
    
            <javaModelGenerator targetPackage="entitytemp" targetProject="srcmain
    esources">
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
    
            <sqlMapGenerator targetPackage="mapper" targetProject="srcmain
    esources"/>
    
            <!--<javaClientGenerator type="XMLMAPPER" targetPackage="net.huadong.mapper" targetProject="srcmainjava"/>-->
    
            <table tableName="system_resources" domainObjectName="SystemResources"
                   enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false"
                   selectByExampleQueryId="false"/>
            <table tableName="system_role_resources" domainObjectName="SystemRoleResources"
                   enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false"
                   selectByExampleQueryId="false"/>
            <table tableName="system_user" domainObjectName="SystemUser"
                   enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false"
                   selectByExampleQueryId="false"/>
            <table tableName="system_role" domainObjectName="SystemRole"
                   enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false"
                   selectByExampleQueryId="false"/>
            <table tableName="system_user_role" domainObjectName="SystemUserRole"
                   enableCountByExample="false" enableUpdateByExample="false"
                   enableDeleteByExample="false" enableSelectByExample="false"
                   selectByExampleQueryId="false"/>
            <!--<table tableName="%">-->
            <!--<generatedKey column="id" sqlStatement="Oracle"/>-->
            <!--</table>-->
        </context>
    </generatorConfiguration>
  • 相关阅读:
    圣杯布局总结
    新手用pyCharm编辑器创建项目不知道如何选择(适用于遇到同样问题的新手)
    支付宝小程序日期选择组件datePicker封装
    关于 WebView 的一些笔记
    ES6学习之箭头函数
    MongoDB--在windows下的安装过程及基本配置
    使用HTML5的canvas做图片剪裁
    git常见操作和常见错误
    算法——找出缺失的整数
    入坑涨姿势
  • 原文地址:https://www.cnblogs.com/CESC4/p/7365364.html
Copyright © 2020-2023  润新知