IDEA15 Generating MyBatis Code

Source: Internet
Author: User

Pom.xml

<build>    <finalName>mybatis_generator</finalName>    <plugins>      <plugin>        <groupId>org.mybatis.generator</groupId>        <artifactid>mybatis-generator-maven-plugin </artifactId>        <version>1.3.  2</version>        <dependencies>          <dependency>            <groupid>mysql</groupid >            <artifactId>mysql-connector-java</artifactId>            <version>5.1.  </version>          </dependency>        </dependencies>      </plugin>    </ Plugins>  </build>

Create a new file under Src->main->resources 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> <!--database driver Jar--<!--<classpathentry location="E:\Project\autoCode\target\mybatis-generator\WEB-INF\lib\mysql-connector-java-5.1.34.jar"/>--> <context id="Db2tables"Targetruntime="Mybatis3simple"> <!--Remove Annotations--<commentGenerator> <property name="suppressallcomments"Value="true"/> </commentGenerator> <!--database connection-<jdbcconnection driverclass="Com.mysql.jdbc.Driver"Connectionurl="jdbc:mysql://localhost:3306/edu"userId="Root"Password="12345678"> </jdbcConnection> <!--default false Java type resolver 'll always use Java.math.BigDecimalifThe database column isof type DECIMAL or NUMERIC. -<!--<javatyperesolver >--> <!--<property name="forcebigdecimals"Value="false"/>--> <!--</javaTypeResolver>--> <!--generate entity classes specify the package name and the generated address (you can customize the address, but the path does not exist and is not automatically created using Maven Generated in target directory, automatically created)-<javamodelgenerator targetpackage="Com.pojo"targetproject="MAVEN"> <!--<property name="enablesubpackages"Value="false"/>--> <!--<property name="trimstrings"Value="true"/>--> </javaModelGenerator> <!--generate Sqlmap Files--<sqlmapgenerator targetpackage="Com.mapper"targetproject="MAVEN"> <property name="enablesubpackages"Value="true"/> </sqlMapGenerator> <!--generate DAO files you can configure type="Xmlmapper"Generate XML for DAO implementation context id="Db2tables"Modify Targetruntime="MyBatis3"-<!--<javaclientgenerator type="SPRING"Targetpackage="Com.qianyan.persistence.dao"targetproject="MAVEN">--> <!--<property name="enablesubpackages"Value="false"/>--> <!--</javaClientGenerator>--> <javaclientgenerator type="Xmlmapper"Targetpackage="Com.imapper"targetproject="MAVEN"> <property name="enablesubpackages"Value="true"/> </javaClientGenerator> <!--corresponding database table MySQL can join the primary key increment field named ignore a field and so on <tab Le Tablename="t_courses"Domainobjectname="tcourses"enableselectbyprimarykey="true"Enableupdatebyprimarykey="true"Enabledeletebyprimarykey="true"enableselectbyexample="false"Enabledeletebyexample="false"enablecountbyexample="false"Enableupdatebyexample="false"> </table> <table tablename="T_courses_chapter"Domainobjectname="Tcourseschapter"enableselectbyprimarykey="true"Enableupdatebyprimarykey="true"Enabledeletebyprimarykey="true"enableselectbyexample="false"Enabledeletebyexample="false"enablecountbyexample="false"Enableupdatebyexample="false"> </table> <table tablename="T_teacher"Domainobjectname="Tteacher"enableselectbyprimarykey="true"Enableupdatebyprimarykey="true"Enabledeletebyprimarykey="true"enableselectbyexample="false"Enabledeletebyexample="false"enablecountbyexample="false"Enableupdatebyexample="false"> </table> <table tablename="t_comments"Domainobjectname="tcomments"enableselectbyprimarykey="true"Enableupdatebyprimarykey="true"Enabledeletebyprimarykey="true"enableselectbyexample="false"Enabledeletebyexample="false"enablecountbyexample="false"Enableupdatebyexample="false"> </table> </context></generatorConfiguration>

Then go to Maven project->mybatis-generator->mybatis-generator:generate right-->run maven Build

If there is no prompt error, the corresponding code will be born in the target file.

IDEA15 Generating MyBatis Code

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.