MyEclipse Install MyBatis Generator code reverse generation tool __mybatis

Source: Internet
Author: User
Tags generator

One, the installation Mybatisgenerator code reverse generation tool

1, Off-line mode:

Download in https://github.com/mybatis/generator/tree/master/eclipse/UpdateSite/

features/

plugins/

Inside all the jar packages, create a new Mybatis-generator folder, features and plugins are thrown into the Mybatis-generator folder, the Mybatis-generator folder moved to D:\ In Myeclipse10_7\myeclipse10\dropins, create a new mbg.link that reads as follows:

Path=d:\myeclipse10_7\myeclipse10\dropins\mybatis-generator

Restart MyEclipse

2. Online mode

Since offline installation is not successful, you can choose to install online

1. Select Help->install from Site ...

2. Click the Add button in the upper-right corner of the dialog box that pops up.

3. In the pop-up dialog box, enter

Name:mybatis

Location:https://dl.bintray.com/mybatis/mybatis-generator

(Location can enter the above address, you can also click Archive, select the Local has already downloaded a good jar, Zip compressed file: org.mybatis.generator.eclipse.site-1.3.5.201609070108.zip)

Click OK

4. Work with select Mybatis-https://dl.bintray.com/mybatis/mybatis-generator or local path of your choice (personal advice to download first, select Local installation, so fast, online installation is too slow)

5. Tick MyBatis Generator Click Next

6. After installation is complete, restart MyEclipse.

Second, the use of mybatisgenerator tools

1. Eclipse mode

1), new project, put the component and config.xml the configuration file to the corresponding directory


2), in the main function to write code to run

public static void Main (string[] args) throws Exception {

list<string> warnings = new arraylist<string> ();

Boolean overwrite = true;

Point to reverse engineering configuration file

File ConfigFile = new file ("Generatorconfig.xml");

Configurationparser cp = new Configurationparser (warnings);

Configuration config = cp.parseconfiguration (configfile);

Defaultshellcallback callback = new Defaultshellcallback (overwrite);

Mybatisgenerator mybatisgenerator = new Mybatisgenerator (config,

callback, warnings);

Mybatisgenerator.generate (NULL);

}

3), to application the way to operate on it

2, MyEclipse Way

1), using MyEclipse to create Java engineering.



Place the Mysql-connector-java-5.1.18.jar in the specified directory entry and configure Generatorconfig.xml.

<?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= "/opt/app-w/gitresp/testcore/src/main/webapp/web-inf/lib/mysql-connector-java-5.1.18.jar"/>

<context id= "Context1" >

<jdbcconnection driverclass= "Com.mysql.jdbc.Driver"

Connectionurl= "Jdbc:mysql://ip:3306/xx?useunicode=true&amp;characterencoding=utf-8"

Userid= "root" password= "123456"/>

<javamodelgenerator targetpackage= "Model"

targetproject= "Testcore"/>

<sqlmapgenerator targetpackage= "Mapper" targetproject= "Testcore"/>

<!--database table name Generation name-->

<javaclientgenerator targetpackage= "Client"

targetproject= "Testcore" type= "Xmlmapper"/>

<table schema= "xx" tablename= "XX"

Domainobjectname= "XX" >

</table>

</context>

</generatorConfiguration> 2), to the GitHub download Mybatis/generator plug-ins, the directory generator/eclipse/ The features and plugins below Updatesite are copied to the corresponding directory under MyEclipse.
3), so you can right-click in the MyEclipse Generatorconfig.xml, find the build mybatis artifacts option, you can generate mapper,model,client, the following figure:

If an error occurs: Unexpectederror while running MyBatis generator. Exception getting JDBC Driver
Which means it's <classpathentry.
location= "/opt/app-w/gitresp/testcore/src/main/webapp/web-inf/lib/mysql-connector-java-5.1.18.jar"/>
There is a problem with the path, the configuration can be resolved!

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.