Eclipse Plugin: MyBatis generator steps to use

Source: Internet
Author: User

First, install the Eclipse plugin

Find in Help--eclipser Marketplace: Mybatis Generator 1.3.5 Installation

Second, new project

new--other--Find the following

Click Next to select the name of the project where you want to generate the file

Click Finish to close. The file Generatorconfig.xml is generated in the HHH project.

Note: The HHH project should have a database-related jar package and the package Mapper/pojo to be generated because it will be configured in the configuration file.

Third, configuration Generatorconfig.xml

[HTML]View PlainCopy
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <! DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en" "/http Mybatis.org/dtd/mybatis-generator-config_1_0.dtd ">
  3. <generatorconfiguration>
  4. <context id="Testtables" targetruntime="MyBatis3">
  5. <commentgenerator>
  6. <!--whether to remove automatically generated comments true: Yes: false: No --
  7. <property name="suppressallcomments" value="true" />
  8. </commentgenerator>
  9. <!--database connection information: Driver class, connection address, user name, password- -
  10. <!--
  11. <jdbcconnection driverclass="Oracle.jdbc.driver.OracleDriver"
  12. connectionurl= "Jdbc:oracle:thin:@150.16.17.22:1521/wsbs" userid="hr "
  13. password="hr123">
  14. </jdbcconnection>-->
  15. <jdbcconnection driverclass="Oracle.jdbc.OracleDriver"
  16. connectionurl="Jdbc:oracle:thin:@150.16.17.22:1521:wsbs"
  17. userid="hr"
  18. password="hr123">
  19. </jdbcconnection>
  20. <!--default False to parse the JDBC decimal and NUMERIC types to Integer, true when JDBC decimal and
  21. NUMERIC type resolution to Java.math.BigDecimal-->
  22. <javatyperesolver>
  23. <property name="forcebigdecimals" value= "false" />
  24. </javatyperesolver>
  25. <!--targetproject: Generate POS Class Location--
  26. <javamodelgenerator targetpackage="Cn.herry.pojo"
  27. targetproject="hhh/src">
  28. <!--enablesubpackages: Do you want the schema to be a suffix of the package--
  29. <property name="enablesubpackages" value= "false" />
  30. <!--The value returned from the database is cleared before and after the space-
  31. <property name="trimstrings" value="true" />
  32. </javamodelgenerator>
  33. <!--targetproject:mapper Map file generated location--
  34. <sqlmapgenerator targetpackage="Cn.herry.mapper"
  35. targetproject="hhh/src">
  36. <!--enablesubpackages: Do you want the schema to be a suffix of the package--
  37. <property name="enablesubpackages" value= "false" />
  38. </sqlmapgenerator>
  39. <!--Targetpackage:mapper interface generated location--
  40. <javaclientgenerator type="Xmlmapper"
  41. targetpackage="Cn.herry.mapper"
  42. targetproject="hhh/src">
  43. <!--enablesubpackages: Do you want the schema to be a suffix of the package--
  44. <property name="enablesubpackages" value= "false" />
  45. </javaclientgenerator>
  46. <!--specifying database tables --
  47. <!--<table tablename= "items" ></table> -
  48. <table tablename="Demo"></table>
  49. </Context>
  50. </generatorconfiguration>


Iv. automatic generation of files such as Mapper.java and Mapper.xml

Right-click Generatorconfig.xml and select the following:

After that, you can see the generated files under the package.

end!

Eclipse Plug-ins: How to use MyBatis generator

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.