generator插件配置方式使用

generator插件配置方式使用

    <build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <configurationFile>${project.basedir}/src/main/resources/mybatis/generatorConfig.xml
                    </configurationFile>
                </configuration>
            </plugin>
        </plugins>
    </build>

generatorConfig.xml:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "mybatis-generator-config_1_0.dtd">

<generatorConfiguration>

    <classPathEntry location="G:\action\flymybatis\src\main\resources\mybatis\mysql-connector-java-5.1.8.jar"/>

    <context id="MysqlTables" targetRuntime="MyBatis3">
        <!--去除注释  -->
        <commentGenerator>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>

        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/mybatis"
                        userId="root"
                        password="root">
        </jdbcConnection>

        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>

        <javaModelGenerator targetPackage="mapper" targetProject="G:\action\flymybatis\src\main\java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="xml" targetProject="G:\action\flymybatis\src\main\resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>

        <javaClientGenerator type="XMLMAPPER" targetPackage="mapper" targetProject="G:\action\flymybatis\src\main\java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>

        <table schema="mybatis" tableName="user" domainObjectName="User">
            <property name="useActualColumnNames" value="false"/>
            <!--<generatedKey column="ID" sqlStatement="DB2" identity="true"/>-->
            <columnOverride column="DATE_FIELD" property="startDate"/>
            <ignoreColumn column="FRED"/>
            <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR"/>
        </table>


    </context>
</generatorConfiguration>

还需要:
mybatis-generator-config_1_0.dtd
mysql-connector-java-5.1.8.jar

posted @ 2019-02-19 09:29  fly_bk  阅读(625)  评论(0编辑  收藏  举报