Mybatis automatically generated code, database PostgreSQL

Source: Internet
Author: User
Tags postgresql

Recently made a project, using MyBatis to generate code automatically, below to do a summary, is later referenced:

First, prepare in advance:

1, Tool class: Mybatis-generator-core-1.3.2.jar

2. PostgreSQL Driver: Postgresql-9.2-1003-jdbc4.jar

3. xml file

I've uploaded them to the attachment. Download Link: Download

Second, XML detailed

Our core configuration file: Mybatisgeneratorconfig.xml

<?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>        <Classpathentry Location= "/users/liqiu/git/study/web/soft/postgresql-9.2-1003-jdbc4.jar" />        <ContextID= "Tts2">                <jdbcconnectionDriverclass= "Org.postgresql.Driver"Connectionurl= "Jdbc:postgresql://l-***.com:5433/crm"userId= "Menpiao_dev"Password= "D**904-8DCE-**D0-BB1B-79***CC">                </jdbcconnection>        <JavamodelgeneratorTargetpackage= "Com.qunar.study.entity"Targetproject= "/users/liqiu/git/study/web/src/main/java">                        < Propertyname= "Enablesubpackages"value= "false" />                        < Propertyname= "Trimstrings"value= "true" />                </Javamodelgenerator>        <SqlmapgeneratorTargetpackage= "MyBatis"Targetproject= "/users/liqiu/git/study/web/src/main/resources/">                </Sqlmapgenerator>        <Javaclientgeneratortype= "Xmlmapper"Targetpackage= "Com.qunar.study.mapper"Targetproject= "/users/liqiu/git/study/web/src/main/java">                        < Propertyname= "Enablesubpackages"value= "false" />                </Javaclientgenerator>                          <TableSchema= "Public"TableName= "Users"Domainobjectname= "Users"></Table>        <TableSchema= "Public"TableName= "Region_manager"Domainobjectname= "Regionmanager"></Table>        <TableSchema= "Public"TableName= "Region"Domainobjectname= "Region"></Table>        <TableSchema= "Public"TableName= "Merchant"Domainobjectname= "Merchant"></Table>        <TableSchema= "Public"TableName= "State_machine"Domainobjectname= "StateMachine"></Table>        <TableSchema= "Public"TableName= "Work_log"Domainobjectname= "Worklog"></Table>        <TableSchema= "Public"TableName= "Contract"Domainobjectname= "Contract"></Table>        <TableSchema= "Public"TableName= "notice"Domainobjectname= "Notice"></Table>        <TableSchema= "Public"TableName= "Contact_person_info"Domainobjectname= "Contactpersoninfo"></Table>        <TableSchema= "Public"TableName= "Express"Domainobjectname= "Express"></Table>        <TableSchema= "Public"TableName= "comment"Domainobjectname= "Comment"></Table>        <!--<table schema= "public" tablename= "operation" Domainobjectname= "Operation" enablecountbyexample= "true" E Nableupdatebyexample= "true" enabledeletebyexample= "true" enableselectbyexample= "true" selectbyexamplequeryid= " True "></table> -        </Context></generatorconfiguration>

Third, the implementation of code:

Java-jar/users/liqiu/git/study/web/soft/mybatis-generator-core-1.3.2/lib/mybatis-generator-core-1.3.2.jar- Configfile/users/liqiu/git/study/web/soft/mybatisgeneratorconfig.xml-overwrite

Then you can see the generated code.

├──src│  ├──main│  │  ├──java│  │  │  ├──com│   │  │  │  └──qunar│  │  │  │   └──study│  │  │  │  ├──entity│  │           │  │  │  ├──comment.java│  │  │  │    │  ├──commentexample.java│  │  │  │  │   ├──contactpersoninfo.java│  │  │  │  │  ├──contactperson Infoexample.java│  │  │  │  │  ├──contract.java│ &nbs P │  │  │  │  ├──contractexample.java│  │  │&nbsp ; │  │  ├──express.java│  │  │  │  │  ├──expressexample.ja Va│  │  │  │  │  ├──merchant.java│  │ &nbs P │  │  │  ├──merchantexample.java│  │  │  │&nbsp  ; │  ├──notice.java│  │  │  │  │   ├──noticeexample.java│  │  │  │  │  ├──operation.java│&n bsp; │  │  │  │  ├──operationexample.java│  │ & nbsp         │  │  │  ├──region.java│  │  │  │   │  ├──regionexample.java│  │  │  │  │  ├ ──regionmanageR.java│  │  │  │  │  ├──regionmanagerexample.java│ &n Bsp │  │  │  │  ├──statemachine.java│  │  │ &n Bsp         │  │  ├──statemachineexample.java│  │  │  │   │  ├──users.java│  │  │  │  │  ├──userse Xample.java│  │  │  │  │  ├──worklog.java│  │&n Bsp; │  │  │  └──worklogexample.java│  │  │ &nb Sp │  └──mapper│  │  │  │  ├──commentmapper.java │  │  │  │  ├──contactpersoninfomapper.java│  │ & nbsp │  │  ├──contractmapper.java│  │  │  │   ├──expressmapper.java│  │  │  │  ├──merchantmapper.java│&nb Sp; │  │  │  ├──noticemapper.java│  │  │ &n Bsp │  ├──operationmapper.java│  │  │  │  ├── Regionmanagermapper.java│  │  │  │  ├──regionmapper.java│ &n Bsp  │  │  │  ├──statemachinemapper.java│  │  │   │  ├──usersmapper.java│  │  │  │  └──wor klogmapper.java│  │  │  └──test│  │  │  └──qunar│& nbsp; │  │  └──com│  │  │  └──web│  │&nbsp     ; │  └──app.java│  │  └──resources│  │   └──mybatis│  │  ├──commentmapper.xml│  │  ├──contactperson Infomapper.xml│  │  ├──contractmapper.xml│  │  ├──expressmap Per.xml│  │  ├──merchantmapper.xml│  │  ├──noticemapper.xml│   │  ├──operationmapper.xml│  │  ├──regionmanagermapper.xml│   │  ├──regionmapper.xml│  │  ├──statemachinemapper.xml│&nbs P; │  ├──usersmapper.xml│  │  └──worklogmapper.xml

Note: The core here is the path, preferably with an absolute path

Related Article

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.