Generator. xml
<? XML version = "1.0" encoding = "UTF-8"?> <! Doctype generatorconfiguration public "-// mybatis.org//dtd mybatis Generator configuration 1.0 //" http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd "> <generatorconfiguration> <! -- Classpathentry: Address of the JDBC driver jar package of the database (changed) xxxxxxxxxxxxxxxxx --> <classpathentry location = "D: \ generator \ mysql-connector-java-5.0.8-bin.jar "/> <context ID =" db2tables "targetruntime =" mybatis3 "> <commentgenerator> <! -- Whether to remove automatically generated comments true: Yes: false: No --> <property name = "suppressallcomments" value = "true"/> <! -- Database connection information: Driver Class, connection address, user name, password (Change) xxxxxxxxxxxxxxx --> </commentgenerator> <jdbcconnection driverclass = "org. gjt. mm. mySQL. driver "connectionurl =" JDBC: mysql: // localhost: 3306/mybatis "userid =" root "Password =" root "> </jdbcconnection> <! -- The default value is false. The JDBC decimal and numeric types are parsed to integer true, and the JDBC decimal and numeric types are parsed to Java. math. bigdecimal --> <javatyperesolver> <property name = "forcebigdecimals" value = "false"/> </javatyperesolver> <! -- Targetproject: automatically generated code location (changed) xxxxxxxxxxxxxxx --> <javamodelgenerator targetpackage = "com. Entity" targetproject = "D: \ generator \ SRC"> <! -- Enablesubpackages: whether to use schema as the package suffix --> <property name = "enablesubpackages" value = "true"/> <! -- Space before and after the value returned from the database --> <property name = "trimstrings" value = "true"/> </javamodelgenerator> <! -- Change xxxxxxxxxxxxxxxxx --> <sqlmapgenerator targetpackage = "com. mapping "targetproject =" D: \ generator \ SRC "> <property name =" enablesubpackages "value =" true "/> </sqlmapgenerator> <javaclientgenerator type =" xmlmapper "targetpackage =" com. mapper "targetproject =" D: \ generator \ SRC "> <property name =" enablesubpackages "value =" true "/> </javaclientgenerator> <! -- Tablename: database table used to automatically generate code; domainobjectname: javaBean class name for the database table --> <Table tablename = "book" domainobjectname = "book" enablecountbyexample = "false" enableupdatebyexample = "false" enabledeletebyexample = "false" enableselectbyexample =" false "selectbyexamplequeryid =" false "> </table> </context> </generatorconfiguration>
Generate statement:
Java-jar mybatis-generator-core-1.3.2.jar-configfile generator. XML-overwrite
Mysql-connector-java-5.0.8-bin.jar
Mybatis-generator-core-1.3.2.jar
:
Http://download.csdn.net/detail/u010653050/5780205
Http://download.csdn.net/detail/u010653050/5780211
Usage:
1. Create a table in the database to generate code in the future.
2. Create a folder generator under the root directory of drive D.
3. Add the following file SRC as an empty folder under the folder to save the generated code.
4. modify the content in the generator. xml file
1. database link information
2. Name of the table in the database
3. Package name
4. If there are more tables, add the table label.
5. Press shift and right-click here to run the command window
6. paste the generated statement into the command window and press enter to run it.
7. The code is generated in the src directory.