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

      新建一个XML文件crmGeneratorConfig.xml,文件具体内容如下。把MybatisGenerator.zip解压出来,把MybatisGenerator文件夹复制到Eclipse安装目录下的dropins文件夹即可,重启Eclipse。在Eclipse中右击crmGeneratorConfig.xml,选择Generate Mybatis/IBATiS Artifacts即可

 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>

 

posted @ 2015-11-23 20:05  季樊  阅读(1381)  评论(0编辑  收藏  举报