MyBatis Genertor Auto-generated Dao+mapping+model

Source: Internet
Author: User

MyBatis genertor Auto-generated Dao+mapping+model

"1" Download:

Refer to: https://github.com/mybatis/generator/releases

The format after decompression:

"2" Add File

Open lib file

(1) New generatorconfig. XML file, see below (for reference only, part of the content needs to be modified by itself):

<?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>

<!-- database-driven

<classpathentry location= "Mysql-connector-java-5.1.30.jar"/>

<context id= "Db2tables" targetruntime= "MyBatis3" >

<commentGenerator>

<!--:* * block * * generated comments contain timestamps, default is false --

<property name= "Suppressdate" value= "true"/>

<!--* * block * * Generate comments, default to false-->

<property name= "Suppressallcomments" value= "true"/>

</commentGenerator>

<!-- Database link Address account password --

<jdbcconnection driverclass= "Com.mysql.jdbc.Driver"

Connectionurl= "Jdbc:mysql:/***.***.***.***:3306/xxx"

Userid= "Root"

Password= "" >

</jdbcConnection>

<javatyperesolver >

<property name= "Forcebigdecimals" value= "false"/>

</javaTypeResolver>

<!-- Generate Model class storage location -

<javamodelgenerator targetpackage= "Test.model" targetproject= "src" >

<property name= "Enablesubpackages" value= "true"/>

<property name= "Trimstrings" value= "true"/>

</javaModelGenerator>

<!-- Generate Map file storage location --

<sqlmapgenerator targetpackage= "test.mapping" targetproject= "src" >

<property name= "Enablesubpackages" value= "true"/>

</sqlMapGenerator>

<!-- Generate a Dao class storage location -

<javaclientgenerator type= "Xmlmapper" targetpackage= "Test.dao" targetproject= "src" >

<property name= "Enablesubpackages" value= "true"/>

</javaClientGenerator>

<!-- generate the corresponding table and class name --

<table tablename= "User"

Domainobjectname= "User"

Enablecountbyexample= "false"

Enableupdatebyexample= "false"

Enabledeletebyexample= "false"

Enableselectbyexample= "false"

Selectbyexamplequeryid= "false" >

</table>

</context>

</generatorConfiguration>

(2): Add mysql connection pack:

"3" Generate statement file:

Java-jar Mybatis-generator-core-1.3.2.jar-configfile Generatorconfig.xml-overwrite

Use of the "4" command:

Hold down the Shift key in the directory and right -click the " Open Command Window here "to copy and paste the file code of the generated statement.

The resulting file is shown below:

MyBatis Genertor Auto-generated Dao+mapping+model

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.