mybatis reverse engineering operation

command:

mvn mybatis-generator:generate

Project structure:

 

generatorConfig.xml example of the contents

<? Xml Version = "1.0" encoding = "UTF-8" ?> 
<! DOCTYPE generatorConfiguration 
        the PUBLIC "- // mybatis.org//DTD the Configuration MyBatis Generator 1.0 // EN" 
        "http://mybatis.org/dtd /mybatis-generator-config_1_0.dtd " > 

< generatorConfiguration > 

    < context ID =" mysqlgenerator " targetRuntime =" MyBatis 3 " > 
        < Property name =" autoDelimitKeywords " value =" to true " /> 
        <-! may be used include fields` ` names, field names to avoid conflicts with reserved words sql error -> 
        <property name="beginningDelimiter" value= "` " /> 
        < Property name =" endingDelimiter " value =" `" /> 

        <-! Automatic generation method toString -> 
        < plugin type = "org.mybatis.generator.plugins.ToStringPlugin" /> 
        <! - automatic generation method and hashcode method equals -> 
        < plugin type = "org.mybatis.generator.plugins.EqualsHashCodePlugin" /> 

        <-! unofficial plug https://github.com/itfsw/mybatis-generator- plugin -> 
        <-! query a single data plug-ins -> 
        < plugin of the type = "com.itfsw.mybatis.generator.plugins.SelectOneByExamplePlugin"/>
        <-! Query results returned to selectively plug -> 
        < plugin of the type = "com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin" /> 
        <! - Example Criteria enhancement plug -> 
        < plugin of the type = "COM. itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin " /> 
        <-! data Model Column attribute corresponding to obtain widget -> 
        < plugin type =" com.itfsw.mybatis.generator.plugins.ModelColumnPlugin " /> 
        <-! logic remove the plug -> 
        < plugin of the type = "com.itfsw.mybatis.generator.plugins.LogicalDeletePlugin" > 
            <!--Here configured global logic values dropping columns and tombstones, of course, arranged in the table covering the global configuration values -> 
            <! - logical delete column type can only be used a number, string, or Boolean type, the database tinyint (. 1) -> 
            < Property name = "logicalDeleteColumn" value = "deleted" /> 
            <-! tombstone - deleted value -> 
            < Property name = "logicalDeleteValue" value = ". 1" /> 
            <! - tombstone - deleted value -> 
            < Property name = "logicalUnDeleteValue" value = "0" /> 
        </ plugin > 

        < commentGenerator >
            <property name="suppressDate" value="true"/>
            <!--<property name="suppressAllComments" value="true"/>-->
        </commentGenerator>

        <!--数据库连接信息-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://192.168.1.100:3306/theorydance?useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC&amp;verifyServerCertificate=false&amp;useSSL=false"
                        userId="root"
                        password="123456"/>

        <javaTypeResolver>
            <property name="useJSR310Types" value="true"/>
        </javaTypeResolver>

        <javaModelGenerator targetPackage="demo.theorydance.db.domain" targetProject="src/main/java"/>
        <sqlMapGenerator targetPackage="demo.theorydance.db.dao" targetProject="src/main/resources"/>
        <javaClientGenerator type="XMLMAPPER" targetPackage="demo.theorydance.db.dao"
                             targetProject="src/main/java"->table name<! -/>
        
        <table tableName="student"></table>
    </context>
</generatorConfiguration>

 

pom.xml to add plug-ins

    <build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.7</version>
                <configuration>
                    <configurationFile>
                        mybatis-generator/generatorConfig.xml
                    </configurationFile>
                    <overwrite>true</overwrite>
                    <verbose>true</verbose>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.46</version>
                    </dependency>
                    <dependency>
                        <groupId>com.itfsw</groupId>
                        <artifactId>mybatis-generator-plugin</artifactId>
                        <version>1.2.12</version>
                    </dependency>
                </dependencies>
            </plugin>

        </plugins>

    </build>

 

Guess you like

Origin www.cnblogs.com/TheoryDance/p/12536374.html