MyBatis-逆向工程

依赖

<build>
    <plugins>
        
        <plugin>
            <groupId>org.mybatis.generatorgroupId>
            <artifactId>mybatis-generator-maven-pluginartifactId>
            <version>1.3.6version>
            <configuration>
                
                <configurationFile>GeneratorMapper.xmlconfigurationFile>
                <verbose>trueverbose>
                <overwrite>trueoverwrite>
            configuration>
            <dependencies>
                
                <dependency>
                    <groupId>mysqlgroupId>
                    <artifactId>mysql-connector-javaartifactId>
                    <version>5.1.49version>
                dependency>
            dependencies>
        plugin>
    plugins>
build>

GeneratorMapper.xml


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="tables" targetRuntime="MyBatis3">
        
        <commentGenerator>
            <property name="suppressAllComments" value="true" />
        commentGenerator>
        
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/test"
                        userId="root"
                        password="root">
        jdbcConnection>
        
        <javaModelGenerator targetPackage="org.example.pojo" targetProject="...\src\main\java">
            <property name="enableSubPackages" value="false" />
            <property name="trimStrings" value="false" />
        javaModelGenerator>
        
        <sqlMapGenerator targetPackage="org.example.mapper" targetProject="...\src\main\java">
            <property name="enableSubPackages" value="false" />
        sqlMapGenerator>
        
        <javaClientGenerator type="XMLMAPPER" targetPackage="org.example.mapper" targetProject="...\src\main\java">
            <property name="enableSubPackages" value="false" />
        javaClientGenerator>
        
        <table tableName="user" domainObjectName="User"
               enableCountByExample="false"
               enableUpdateByExample="false"
               enableDeleteByExample="false"
               enableSelectByExample="false"
               selectByExampleQueryId="false"/>
    context>
generatorConfiguration>

在maven中,找到当前模块下的MyBatis生成插件,双击开始生成
MyBatis-逆向工程_第1张图片

你可能感兴趣的:(mybatis)