Reverse engineering of springboot + mybats has the process of generating domain from database

Environment: jdk1.8 (for springboot2.X and above)

Maven (above 3.3. X)

          spring boot 2.1.6

          Idea 2019.1\

        

 

 

Fill it in here

 

  

Select the corresponding Jar, as shown below

 

The following is the most important operation. In pom.xml, import the jar required by mybats reverse engineering.

 

Configure the corresponding required code in pom.xml. Here we have a separate < plugle > < plugle >, which belongs to the same rating as the previous (generated automatically by idea).

 

Configure the generatorConfig.xml file under the path of src/main/resources /. Note that the database driver here is on your computer's hard disk or in your maven's warehouse.

<?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">
<!--utilize MyBatis Generator Inside Xml File format, copying to resource Of xml Document and make changes-->
<generatorConfiguration>
    <!--find MySQL Path to drive package-->
    <classPathEntry location="E:\maven\repository\mysql\mysql-connector-java\5.1.28\mysql-connector-java-5.1.28.jar" />
    <!--configure connections MySQL Database information-->
    <context id="inputdb" targetRuntime="MyBatis3">
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/test"
                        userId="root"
                        password="root">
        </jdbcConnection>
        <!--We'll put it in the database. int Type data to Java Li bigDecimals -->
        <javaTypeResolver >
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
        <!--Configure relative and project paths for individual files-->
        <!--Generate entity class, need and App They are at the same level.-->
        <javaModelGenerator targetPackage="com.kay.entity" targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
        <!--Mapping file, must be in resources Medium-->
        <sqlMapGenerator targetPackage="mapper"  targetProject="src/main/resources">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
        <!--Bottom dao-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.kay.dao"  targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <!--take example Type set as false,Otherwise, there will be one more entity class example Class exampleStudent -->
        <!--Show as database, generate entity class Student,Automatically generated to entity Directory-->
        <table tableName="user" domainObjectName="Area" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false">
        </table>


    </context>
</generatorConfiguration>

 

Explanation

Finally, the generation process

Tags: SQL Sever MySQL xml Mybatis Java

Posted on Sun, 03 Nov 2019 01:45:46 -0700 by stone.cold.steve.austin