IntelliJ idea 2017 version spring-boot2.0.4+mybatis reverse engineering; MYBATIS+SPRINGBOOT Reverse engineering

Source: Internet
Author: User

I. Building the Environment

Using the IDE to automatically build project methods

Then, next

Next, configure the import dependency package

The project is generated, and the configuration file Generatormapper.xml (project structure) is imported under the project

Configuring documents to establish database and database connections

1 <?XML version= "1.0" encoding= "UTF-8"?> <!DOCTYPE generatorconfiguration Public2 "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en"3 "Http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">4 5 <!--Reverse Engineering Configuration document -6 <generatorconfiguration>7 8     <!--Specify the location of the JDBC driver package that connects to the database, specifying the full path to your local machine -9     <ClasspathentryTen              Location= "D:/users/liuya/repository/mysql/mysql-connector-java/5.1.46/mysql-connector-java-5.1.46.jar"/> One  A     <!--Configure tables Table content body, targetruntime specify version with MyBatis3 - -     <ContextID= "Tables"Targetruntime= "MyBatis3"> -  the         <!--suppresses the generation of comments, because the generated comments are in English, you can not let it generate - -         <Commentgenerator> -             < Propertyname= "Suppressdate"value= "true"/> -         </Commentgenerator> +  -         <!--Configure database connection information - +         <jdbcconnectionDriverclass= "Com.mysql.jdbc.Driver" A Connectionurl= "jdbc:mysql://localhost:3306/p2p" at userId= "root" - Password= "123456"> -  -         </jdbcconnection> -  -         <!--generates the model class, Targetpackage specifies the package name of the model class, Targetproject specifies which project the generated model is placed under in the compiler - in         <JavamodelgeneratorTargetpackage= "Com.springboot.mybatis.model"Targetproject= "Src/main/java"> -             < Propertyname= "Enablesubpackages"value= "false"/> to             < Propertyname= "Trimstrings"value= "false"/> +         </Javamodelgenerator> -  the         <!--generate the Mapper.xml file for MyBatis, targetpackage specify the package name of the Mapper.xml file, targetproject specify which project of the generated mapper.xml is placed under the compiler - *         <SqlmapgeneratorTargetpackage= "Com.springboot.mybatis.mapper"Targetproject= "Src/main/java"> $             < Propertyname= "Enablesubpackages"value= "false"/>Panax Notoginseng         </Sqlmapgenerator> -  the         <!--Generate the Mapper interface class file for the MyBatis, targetpackage specify the package name of the Mapper interface class file, Targetproject specifies which project the generated Mapper interface class file is placed under in the compiler - +         <Javaclientgeneratortype= "Xmlmapper"Targetpackage= "Com.springboot.mybatis.mapper"Targetproject= "Src/main/java"> A             < Propertyname= "Enablesubpackages"value= "false"/> the         </Javaclientgenerator> +  -         <!--database table name and corresponding Java model class name, if more than one table, configure the bottom multiple, only the table name switch - $         <TableTableName= "Student" $ Domainobjectname= "Student" - Enablecountbyexample= "false" - Enabledeletebyexample= "false" the Enableselectbyexample= "false" - Enableupdatebyexample= "false"Wuyi Selectbyexamplequeryid= "false" the  -         /> Wu     </Context> - </generatorconfiguration>
View Code

Official documents and database storage location

Two. Run the configuration document,

After the successful generatormapper is established, MAVEN is updated to the right to generate

Double-click inside the Circle

To generate the relevant configuration file

Three. Project Code package

Https://github.com/liushaoye/01-springboot-mybatis/tree/master

IntelliJ idea 2017 version spring-boot2.0.4+mybatis reverse engineering; MYBATIS+SPRINGBOOT Reverse engineering

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.