One, install generator in MyEclipse
You can select the install from site:http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/in the MyEclipse updatesite/
Second, generate each layer class
In the SRC directory, add the generated 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-->< Classpathentry location= "H:\mysql-connector-java-5.1.7-bin.jar"/><!--Configure absolute path--><!--Configure Data source connections-->< Context id= "Aissnstables" targetruntime= "Ibatis2java5" ><jdbcconnection driverclass= "Com.mysql.jdbc.Driver" Connectionurl= "Jdbc:mysql://localhost:3306/mybatis" userid= "root" password= "" ></jdbcConnection>< Javatyperesolver><property name= "Forcebigdecimals" value= "false"/></javatyperesolver><!-- Targetpackage: Generated Pojo into the package, Targetproject: generated Pojo put into the project (corresponding to the workspace of the project)--><javamodelgenerator targetpackage= " ShuiTian.NaiLuo.po "targetproject=" shopping/src "><property name=" Enablesubpackages "value=" false "/>< Property Name= "Trimstrings" value= "false"/></javamodelgenerator><!--targetpackage= generated SQL corresponds to the package targetproject: the generated SQL interface corresponds to the project--><sqlmapgenerator targetpackage= " ShuiTian.NaiLuo.mapper "targetproject=" shopping/src "><property name=" Enablesubpackages "value=" false "/> </sqlMapGenerator><!--targetpackage: Generated DAO interface corresponding to package Targetproject: Generated DAO interface corresponding project type: Mapping file type, generally xmlmapper-- ><javaclientgenerator type= "SPRING" targetpackage= "ShuiTian.NaiLuo.service.impl" implementationpackage= " ShuiTian.NaiLuo.service.impl "targetproject=" shopping/src "><property name=" Enablesubpackages "value=" false " /></javaclientgenerator><!--which tables to generate--><table tablename= "items" domainobjectname= "items" Enableinsert= "true" enableselectbyprimarykey= "true" enableupdatebyprimarykey= "true" enabledeletebyprimarykey= " True "enableselectbyexample=" false "enabledeletebyexample=" false "enablecountbyexample=" false " Enableupdatebyexample= "false" ></table><table tablename= "OrderDetail" domainobjectname= "OrderDetail" Enableinsert= "true" enablesElectbyprimarykey= "true" enableupdatebyprimarykey= "true" enabledeletebyprimarykey= "true" enableselectbyexample= " False "enabledeletebyexample=" false "enablecountbyexample=" false "enableupdatebyexample=" false "></table> <table tablename= "Orders" domainobjectname= "Orders" enableinsert= "true" enableselectbyprimarykey= "true" Enableupdatebyprimarykey= "true" enabledeletebyprimarykey= "true" enableselectbyexample= "false" Enabledeletebyexample= "false" enablecountbyexample= "false" enableupdatebyexample= "false" ></table>< Table tablename= "User" domainobjectname= "user" enableinsert= "true" enableselectbyprimarykey= "true" Enableupdatebyprimarykey= "true" enabledeletebyprimarykey= "true" enableselectbyexample= "false" Enabledeletebyexample= "false" enablecountbyexample= "false" enableupdatebyexample= "false" ></table></ Context></generatorconfiguration>
Then right-click on the configuration file:
ok~~~~~
Third, some notes on the configuration file
1, the database driver package should be configured as absolute path, preferably not Chinese.
2, Sleepy =_=!.
Mybatis-generator generating Basic code automatically