Springboot Automatically generate mapper mappings

Source: Internet
Author: User
Tags generator
Project Structure

If the project uses the relational database, cooperate with the Ibatis use, only needs to establish the database table to be OK, other will give the plug-in to do. Add in 1.pom file

<build>
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactid >mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                < Configuration>
                    <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml< /configurationfile>
                    <overwrite>true</overwrite>
                    <verbose>true</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>
2. Add a configuration file to the resources
Resource
|____generator
| |____generatorconfig.xml
<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis generator Configuration" "1.0//en S.org/dtd/mybatis-generator-config_1_0.dtd "> <!--usage: MVN mybatis-generator:generate--> < Generatorconfiguration> <!--Read the configuration file address--> <properties resource= "application-test.properties"/> <!- -Connection driver to determine the address--> <classpathentry location= "/users/liuxin/desktop/postgresql-42.0.0.jre6 2.jar"/> <contex T id= "Context1" targetruntime= "Mybatis3simple" defaultmodeltype= "flat" > <property name= "Beginningdelimiter" Value= "" "/> <property name=" endingdelimiter "value=" '/> <jdbcconnection ' driverclass= Tgresql.
                        Driver "Connectionurl=" ${druid.url} "userid=" ${druid.username} " Password= "${druid.password}" > </jdbcConnection> <!--entity classes are also not built in advance, and willAutomatically according to the database generation, the corresponding database field--> <javamodelgenerator targetpackage= "Pterosaur.account.domain" targetproject= "src/main/" Java "/> <!--mapped mapper.xml files--> <sqlmapgenerator targetpackage=" mapper "targetproject=" Src/main /resources "/> <!--mapping file, the target does not need to be built ahead of time and automatically generates--> <javaclientgenerator targetpackage=" Pterosaur.account . Mapper "targetproject=" Src/main/java "type=" Xmlmapper "/> <!--input indicates that the table name does not correspond to the entity Dynamic judgment--> <table tablename= "Boluome_flow" ></table> <table tablename= "Boluome_refund_flow" & gt;</table> <table tablename= "boluome_refund_seettlement" ></table> <table tablename= " Boluome_settlement "></table> <table tablename=" Boss_settlement_account "></table> < Table Tablename= "Boss_transaction_flow" ></table> <table tablename= "Settlement_account" ></table&
        Gt <table tablEname= "User_settlement_account" ></table> <table tablename= "User_transcation_flow" ></table> </context> </generatorConfiguration>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.