【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:\MavenRepository\mysql\mysql-connector-java\5.1.37\mysql-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="src\main\resources">
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="mapper" targetProject="src\main\resources"/>

        <!--<javaClientGenerator type="XMLMAPPER" targetPackage="net.huadong.mapper" targetProject="src\main\java"/>-->

        <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>

 

posted @ 2017-08-15 15:29  Legolas_4  阅读(207)  评论(0编辑  收藏  举报