Mybatis-generator generating Basic code automatically

Source: Internet
Author: User


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

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.