自動生成Mapper和Entity工具MybatisGenerator的使用

      新建一個XML文件crmGeneratorConfig.xml,文件具體內容以下。把MybatisGenerator.zip解壓出來,把MybatisGenerator文件夾複製到Eclipse安裝目錄下的dropins文件夾便可,重啓Eclipse。在Eclipse中右擊crmGeneratorConfig.xml,選擇Generate Mybatis/IBATiS Artifacts便可java

 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         <!-- 數據庫驅動位置 -->
 5         <classPathEntry location="D:\new_eclipse\apache-tomcat-6.0.41-YJT\lib\mysql-connector-java-5.1.34.jar" />
 6         
 7         <context id="BaseDataTables" targetRuntime="MyBatis3">
 8                 <!-- 是否去除自動生成的註釋 true:是 : false:否 -->
 9                 <commentGenerator>
10             <property name="suppressAllComments" value="true" />
11         </commentGenerator>
12                 <!-- 數據庫鏈接參數 -->
13                 <jdbcConnection driverClass="com.mysql.jdbc.Driver"
14                         connectionURL="jdbc:mysql://192.168.1.224:3306/olymtech_basic?useUnicode=true&amp;characterEncoding=UTF-8" userId="saas1"
15                         password="olymtech1" />
16                 <!--把JDBC DECIMAL 和  NUMERIC 類型解析爲java.math.BigDecimal. (默認false,即把JDBC DECIMAL 和 NUMERIC 類型解析爲 Integer ) -->
17         <javaTypeResolver>
18             <property name="forceBigDecimals" value="false" />
19         </javaTypeResolver>
20                 <!-- entity存放目錄 -->
21                 <javaModelGenerator targetPackage="com.olymtech.cs.base.datads.entiy" targetProject="base-datads" />
22                 <!-- mapper xml存放目錄 -->
23                 <sqlMapGenerator targetPackage="config.mappers" targetProject="base-datads" />
24                 <!-- mapper接口存放目錄 
25                 <javaClientGenerator targetPackage="com.olymtech.boss.crm.dao" targetProject="com.olymtech.boss.crm" type="XMLMAPPER" />
26                 -->
27                 <!--對應數據庫表 mysql能夠加入主鍵自增 字段命名 忽略某字段等
28                 <table schema="ProcessManagement" tableName="process_management"/>
29                 <table schema="ProcessEmployeeRela" tableName="process_employee_rela"/> -->
30         <!--         <table schema="Airport" tableName="airport"/>
31                 <table schema="Carrier" tableName="carrier"/>
32                 <table schema="Route" tableName="route"/>
33                 <table schema="Seaport" tableName="seaport"/> -->
34                 <table schema="countryRouteRela" tableName="country_route_rela"/>
35         </context>
36 </generatorConfiguration>
相關文章
相關標籤/搜索