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