generator code generator

generator code generator


The scope of the code generator is
mainly single-table (no multi-table is found)

Operation flow
1:
Show some below in the parent class pom mapping package 内联代码片.

   <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.7</version>
                <configuration>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                    <configurationFile>src/main/resources/generator/generatorConfig.xml</configurationFile>
                </configuration>
                <dependencies>
                    <!-- 数据库驱动 -->
                        <dependency>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>5.1.37</version>
                        </dependency>
                </dependencies>
            </plugin>

2: Create a new corresponding file in the configurationFile in the security pom
Insert picture description here
3: Write the corresponding generatorConfig.xml configuration file

<?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>
    <!-- <properties resource="generator.properties"/>-->
    <context id="Mysql" targetRuntime="MyBatis3" defaultModelType="flat">
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>
        <!-- <property name="javaFileEncoding" value="UTF-8"/>-->
        <!-- 为模型生成序列化方法-->
        <!--<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>-->
        <!-- 为生成的Java模型创建一个toString方法 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
        <!--覆盖生成XML文件-->
        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
        <commentGenerator>
            <!-- 是否去除自动生成的注释 true:是 : false:-->
            <property name="suppressAllComments" value="true"/>
            <!--<property name="suppressDate" value="true"/>
            <property name="addRemarkComments" value="true"/>-->
        </commentGenerator>

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

        <javaModelGenerator targetPackage="com.course.server.domian" targetProject="src\main\java"/>
        <sqlMapGenerator targetPackage="mapper" targetProject="src\main\resources"/>
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.course.server.mapper"
                             targetProject="src\main\java"/>
        <!--生成全部表tableName设为%-->
        <table tableName="Test" domainObjectName="Test"/>
    </context>
</generatorConfiguration>

4: Create a run class
Insert picture description here
Insert picture description here
Insert picture description here
Click run to map the corresponding configuration, and
Insert picture description here
this is done

Guess you like

Origin blog.csdn.net/m0_49056832/article/details/108850028