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 Generator Configuration 1.0//EN"
<!--utilize MyBatis Generator Inside Xml File format, copying to resource Of xml Document and make changes-->
    <!--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"
        <!--We'll put it in the database. int Type data to Java Li bigDecimals -->
        <javaTypeResolver >
            <property name="forceBigDecimals" value="false" />
        <!--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" />
        <!--Mapping file, must be in resources Medium-->
        <sqlMapGenerator targetPackage="mapper"  targetProject="src/main/resources">
            <property name="enableSubPackages" value="true" />
        <!--Bottom dao-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.kay.dao"  targetProject="src/main/java">
            <property name="enableSubPackages" value="true" />

        <!--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">




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