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