Installation and use of MyBatis generator plug-ins in eclipse

Source: Internet
Author: User
Tags generator

MyBatis can also generate code in the direction of generating entity Class (PO), mapper interface and Mapper interface mapping file, can reduce the workload of our Code. Detailed steps are as follows

1, download MyBatis Generation Rack Package tool Mybatis_generator_1.3.1.zip, decompression rack package to features, plugins folder under the package to copy to the Eclipse installation directory features, plugins folder. It's OK to restart Eclipse.

After decompression the picture is as follows:


The eclipse path is shown in figure:


Copy Replacement as shown:


2, create generatorconfig.xml files, install a good mybatis can be created Generatorconfig.xml


3, configuration generatorconfig.xml configuration file, detailed as follows

<?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> <!--<classpathentry location= "D:\rep\mysql\mysql-connector-java\5.1.19\mysql-connector-java-5.1.19.jar"/>--> < Classpathentry location= "D:\repo\com\oracle\ojdbc14\10.2.0.1.0\ojdbc14-10.2.0.1.0.jar"/> <context id= " Db2tables "targetruntime=" MyBatis3 "> <commentGenerator> <property name=" suppressallcomments "value=" True '/> <property name= ' suppressdate value= ' true '/> </commentGenerator> <jdbcconnection driv erclass= "Oracle.jdbc.driver.OracleDriver" connectionurl= Jdbc:oracle:thin: @xxx. Xxx.xxx.xxx:1521:orcl4 "Userid=" xxx "password=" xxxx "/> <javaTypeResolver> <property name=" Forcebigdecimals "value=" false "/> < !--default False to resolve the JDBC DECIMAL and NUMERIC types toInteger true to resolve the JDBC DECIMAL and NUMERIC types to Java.math.BigDecimal--> </javaTypeResolver> <javamodelgenerato R targetpackage= "Com.pcmall.domain.sale.order" targetproject= "Pos-service/src/main/java" > <property name= "

		Enablesubpackages "value=" true "/> <property name=" trimstrings "value=" true "/> </javaModelGenerator>
			<sqlmapgenerator targetpackage= "Mybatis.mapper.sale.order" targetproject= "Pos-service/src/main/resources" > <property name= "Enablesubpackages" value= "false"/> </sqlMapGenerator> <javaclientgenerator Targetpac Kage= "Com.pcmall.dao.sale.order" targetproject= "Pos-service/src/main/java" type= "Xmlmapper" > <property name= "Enablesubpackages" value= "false"/> </javaClientGenerator> <table tablename= "HS_ZXZFLX" Enableselectbye Xample= "false" enabledeletebyexample= "false" enablecountbyexample= "false" selectbyexamplequeryid= "true" Enableupdatebyexample= "false" > <!--&LT;GENERATEDKEY column= "ID" sqlstatement= "Oracle" identity= "true"/>--> </table> </context> </generatorconfig Uration>
4, right click Generatorconfig.xml click Generate mybatis/ibatis artifacts generate corresponding interface, interface mapping file, entity class

5, view the results

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.