• generator代码快速生成


    generator代码快速生成

    在pom中导入插件

    <plugin>
        <!--Mybatis-generator插件,用于自动生成Mapper和POJO-->
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
            <!--配置文件的位置-->
            <configurationFile>src/main/resources/mybatis-generator-config.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>
        </dependencies>
    </plugin>
    

    编写mybatis-generator-config.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>
    
        <!-- 本地数据库驱动程序jar包的全路径 -->
        <classPathEntry location="E:开发MYSQLjar包mysql-connector-java-5.1.46.jar"/>
    
        <context id="context" targetRuntime="MyBatis3">
            <commentGenerator>
                <!--为true不生成注释和时间戳-->
                <property name="suppressAllComments" value="true"/>
                <property name="suppressDate" value="true"/>
            </commentGenerator>
    
            <!-- 数据库的相关配置 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/demo" userId="root" password="root"/>
    
            <javaTypeResolver>
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
    
            <!-- 实体类生成的位置 -->
            <javaModelGenerator targetPackage="com.mlyr.pojo" targetProject="src/main/java">
                <property name="enableSubPackages" value="false"/>
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
    
            <!-- *Mapper.xml 文件的位置 -->
            <sqlMapGenerator targetPackage="com.mlyr.mapper" targetProject="src/main/java">
                <property name="enableSubPackages" value="false"/>
            </sqlMapGenerator>
    
            <!-- Mapper 接口文件的位置 -->
            <javaClientGenerator targetPackage="com.mlyr.mapper" targetProject="src/main/java" type="XMLMAPPER">
                <property name="enableSubPackages" value="false"/>
            </javaClientGenerator>
    
            <!-- 相关表的配置 -->
            <table tableName="emp" enableCountByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
                   enableUpdateByExample="true"/>
             <!-- 一次生成多张表 -->
            <table tableName="dept" enableCountByExample="true" enableDeleteByExample="true" enableSelectByExample="true"
                   enableUpdateByExample="true"/>
        </context>
    </generatorConfiguration>
    

    直接生成

    image-20210313172751749

    不经风雨,怎见彩虹?
  • 相关阅读:
    龙小树|第一篇博客随笔
    机器学习相关网址
    希腊字母表
    博客园美化
    论文检索常用网站
    这些年,我用过的良心网站,分享给大家
    MATLAB小函数:展示灰度图像数据集的部分样例
    基于图嵌入的高斯混合变分自编码器的深度聚类(Deep Clustering by Gaussian Mixture Variational Autoencoders with Graph Embedding, DGG)
    MATLAB实例:二维散点图
    MATLAB实例:多元函数拟合(线性与非线性)
  • 原文地址:https://www.cnblogs.com/MLYR/p/14529663.html
Copyright © 2020-2023  润新知