"Java MyBatis Generator" uses Generator to automatically generate dao,mapping and entity files

Source: Internet
Author: User

For details, please refer to:

http://blog.csdn.net/fengshizty/article/details/43086833

Follow the above blog address to download the generator dependency package:

Here is my configuration file:

<?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 driver Package location -    <Classpathentry Location= "C:\Generate\generator\generator\mysql-connector-java-5.1.34.jar" />     <!--<classpathentry location= "C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar"/> -    <ContextID= "Db2tables"Targetruntime= "MyBatis3">        <Commentgenerator>            < Propertyname= "Suppressallcomments"value= "true" />        </Commentgenerator>        <!--database link URL, user name, password -         <jdbcconnection driverclass= "Com.mysql.jdbc.Driver" connectionurl= "jdbc:mysql://localhost:3306/ Testmybatis "userid=" root "password=" XXXXX ">        <!--<jdbcconnection driverclass= "Oracle.jdbc.driver.OracleDriver" connectionurl= "Jdbc:oracle:thin: @localhost : 1521:orcl "userid=" MSA "password=" MSA > -        </jdbcconnection>        <Javatyperesolver>            < Propertyname= "Forcebigdecimals"value= "false" />        </Javatyperesolver>        <!--Build the package name and location of the model -        <javamodelgenerator targetpackage= "Com.zlg.model" targetproject= "C:\GENERATE\GENERATOR\GENERATOR\SRC" >            < Propertyname= "Enablesubpackages"value= "true" />            < Propertyname= "Trimstrings"value= "true" />        </Javamodelgenerator>        <!--generated map file package name and location -       <sqlmapgenerator targetpackage= "com.zlg.mapping" targetproject= "C:\GENERATE\GENERATOR\GENERATOR\SRC" >             < Propertyname= "Enablesubpackages"value= "true" />        </Sqlmapgenerator>        <!--generate DAO's package name and location -         <javaclientgenerator  type= "Xmlmapper"  targetpackage= " Com.zlg.dao "  targetproject=" C:\Generate\generator\generator\src ">             < Propertyname= "Enablesubpackages"value= "true" />        </Javaclientgenerator>        <!--to generate those tables (change tablename and Domainobjectname) -        <table tablename= "user" Domainobjectname = "UserInfo"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false" />        <TableTableName= "Dept"Domainobjectname= "Deptinfo"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false" />        <TableTableName= "EMP"Domainobjectname= "Empinfo"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false" />        <TableTableName= "Cost"Domainobjectname= "Costinfo"Enablecountbyexample= "false"Enableupdatebyexample= "false"Enabledeletebyexample= "false"Enableselectbyexample= "false"Selectbyexamplequeryid= "false" />    </Context></generatorconfiguration>

Depending on the location of the tag in the configuration file above, modify it to the location you want, and then run the following command (remember to use the TAB key to complete the command, which is known by CMD or Linux).

After successful operation, the following files are generated:

Of course, if you are lazy, you can directly set the build path to the corresponding location of your project.

At this point, you can copy the corresponding files to the relevant location of the project. It's very simple, and the author of the link above has written it in detail.

Thanks for sharing ~

"Java MyBatis Generator" uses Generator to automatically generate dao,mapping and entity files

Related Article

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.