MyEclipse Configuring Mybatis_generator Generation Mapper,model,client

Source: Internet
Author: User

When using MyBatis docking data, manual write Mapper,model,client will be time-consuming, you can try mybatis_gererator to generate more difficult mybatis configuration files.
Start with MyEclipse to create the Java project.

Place the Mysql-connector-java-5.1.18.jar in the specified directory project and configure Generatorconfig.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>    <classpathentrylocation ="/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 to generate a name --        <javaclientgenerator targetpackage= "client"targetproject=" Testcore " type=" Xmlmapper "/>                    <table Schema="xx " tableName="xx " Domainobjectname="xx">                    </table>    </Context></generatorconfiguration>

Then download the Mybatis/generator plugin on GitHub, git clone https://github.com/mybatis/generator.git. and put the directory generator/eclipse/ Updatesite the following features and plugins are copied to the myeclipse corresponding directory.
You can then right-click the generatorconfig.xml in MyEclipse and find the Generate mybatis artifacts option to generate mapper,model,client, such as:

If an error occurs: Unexpected error while running MyBatis Generator. Exception getting JDBC Driver
That's what <classPathEntry
location="/opt/app-w/gitresp/testcore/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.18.jar" />
it means.
There is a problem with the path, the configuration can be solved!

MyEclipse Configuring Mybatis_generator Generation Mapper,model,client

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.