Automatic generation of DAO, Model, mapping related files using Mybatis-generator

Source: Internet
Author: User

Preparatory work:
1. Database Drivers
2.generatorConfig Drive, (: https://github.com/mybatis/generator/releases)
3.generatorconfig.xml configuration file, as follows (note: This file cannot be commented on while it is running.) ):
<?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= "Webroot/web-inf/lib/mysql-connector-java-5.1.8-bin.jar"/>
<context id= "Db2tables" targetruntime= "MyBatis3" >
<commentGenerator>
<property name= "Suppressdate" value= "true"/>
<property name= "Suppressallcomments" value= "true"/>
</commentGenerator>
<!--database link Address account password--
<jdbcconnection driverclass= "Com.mysql.jdbc.Driver" connectionurl= "Jdbc:mysql://192.168.1.88:3306/test" userId = "Zhengshou" password= "123456" >
</jdbcConnection>
<javaTypeResolver>
<property name= "Forcebigdecimals" value= "false"/>
</javaTypeResolver>
<!--generate model class storage location-
<javamodelgenerator targetpackage= "Com.adon.model" targetproject= "src" >
<property name= "Enablesubpackages" value= "true"/>
<property name= "Trimstrings" value= "true"/>
</javaModelGenerator>
<!--generate Map file storage location--
<sqlmapgenerator targetpackage= "com.adon.mapping" targetproject= "src" >
<property name= "Enablesubpackages" value= "true"/>
</sqlMapGenerator>
<!--generate a DAO class storage location-
<javaclientgenerator type= "Xmlmapper" targetpackage= "Com.adon.dao" targetproject= "src" >
<property name= "Enablesubpackages" value= "true"/>
</javaClientGenerator>
<!--generate the corresponding table and class name, TableName and domainobjectname are required, respectively, represent the database table name and generated strength class name, the rest can be customized to choose (generally false). -
<table tablename= "user" domainobjectname= "user" enablecountbyexample= "false" enableupdatebyexample= "false" Enabledeletebyexample= "false" enableselectbyexample= "false" Selectbyexamplequeryid= "false" ></table>
</context>
</generatorConfiguration>


Open cmd, go to the project root directory, run the code (note the path problem):
Java-jar Webroot/web-inf/lib/mybatis-generator-core-1.3.2.jar-configfile Src/config/generatorconfig.xml- Overwrite



Automatic generation of DAO, Model, mapping related files using Mybatis-generator

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.