MYBATIS+ECLIPSE Reverse Engineering

Source: Internet
Author: User
Tags generator

The first step: If your eclipse does not install the MyBatis plug-in, you need to install the MyBatis plugin, plugin download address: Click to open the link

Step two: After downloading the plugin, unzip the following two files


Step three: Locate the Eclipse installation directory and copy the two files to the Eclipse installation directory


If these two files already exist in the installation directory, the two files will be merged.

Step Fourth: Restart Eclipse

Click ' New--other ' to find MyBatis plug-ins in eclipse


Step Fifth: Select MyBatis generator Configuration file Click Next to create profile information


Select the location where you want to create the file, click Finish

Step Sixth: Configure the response information in the created file to


Note: Configuration file parsing

<pre name= "code" class= "HTML" ><?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis generator Configuration" "1.0//en Mybatis.org/dtd/mybatis-generator-config_1_0.dtd "> <generatorconfiguration > <!--Introducing configuration files--> < Properties resource= "Db.properties"/> <!--specify data connection driver jar address--> <classpathentry location= "${classpath}"/ > <!--a database a context--> <context id= "Context1" > <!--notes--> <commentGenerator> & Lt;property name= "Suppressallcomments" value= "false"/><!--to uncomment--> <property name= "Supperssdate" value = ' true '/><!--generate comment code timestamp--> </commentGenerator> <!--JDBC Connection--> <jdbcconnection Drive rclass= "${jdbc.driver}" connectionurl= "${jdbc.url}" userid= "${jdbc.username}" password= "${jdbc.password}"/ > <!--type conversion--> <javaTypeResolver> <!--whether to use Bigdecimals,fAlse can automatically convert the following types (long,integer,short,ets.)--> <property name= "Forcebigdecimals" value= "false"/> Yperesolver> <!--generate entity class address--> <javamodelgenerator targetpackage= "Com.sky.ssm.po" targetproject= ECT} "> <!--whether to add a new layer of Schema,eg:fase path under the current path: Com.sky.ssm.po; True path: Com.sky.ssm.po. [Shemaname]--> <property name= ' enablesubpackages ' value= ' false '/> <!--whether a string type of field is set Make Trim call--> <property name= "trimstrings" value= "true"/> </javaModelGenerator> <!--generation MAPXM L file--> <sqlmapgenerator targetpackage= "Com.sky.ssm.mapper" targetproject= "${project}" > <!--is under the current path New Layer Schema,eg:fase Path: Com.sky.ssm.mapper true path: Com.sky.ssm.mapper. [Shemaname]--> <property name= "Enablesubpackages" value= "false"/> </sqlMapGenerator> &L t;! --Generate mapxml corresponding to the client, which is the interface DAO--> <javaclientgenerator targetpackage= "Com.sky.ssm.mapPer "targetproject=" ${project} "type=" Xmlmapper "> <!--whether to add a new layer of Schema,eg:fase path under the current path: com.sky.ssm.ma Pper true path: Com.sky.ssm.mapper.
    [Shemaname]--> <property name= "Enablesubpackages" value= "false"/> </javaClientGenerator> <!--configuration table information--> <!--schema is the database name, TableName is the corresponding database table, Domainobjectname is the entity class to be generated, enable*byexample whether to generate Exampl
    	Class E--> <table schema= "MyBatis" tablename= "items" domainobjectname= "items" enablecountbyexample= "false" Enabledeletebyexample= "false" enableselectbyexample= "false" enableupdatebyexample= "false" > <!--ignore column, do not generate B EAN fields--> <!--<ignorecolumn column= "FRED"/>--> <!--the Java data type of the specified column--> <!--<co Lumnoverride column= "Price" javatype= "Double"/>--> </table> </context> </generatorconfigurati On>

Db.properties

Jdbc.username = root
Jdbc.password = 123456
jdbc.url = jdbc:mysql://localhost:3306/mybatis
jdbc.driver = Com.mysql.jdbc.Driver

#Mybatis Generator configuration  
project = Springmvcandmybatis
classpath = g:/ Myproject/springmvcandmybatis/webroot/web-inf/lib/mysql-connector-java-5.1.20-bin.jar

Step seventh: Reverse code generation


After the operation is successful, you can see the response Mapper and model files in the response package.


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.