您的位置:首页 > 移动开发

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

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

<?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>
<!-- 数据库驱动位置 -->
<classPathEntry location="D:\new_eclipse\apache-tomcat-6.0.41-YJT\lib\mysql-connector-java-5.1.34.jar" />

<context id="BaseDataTables" targetRuntime="MyBatis3">
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- 数据库连接参数 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.1.224:3306/olymtech_basic?useUnicode=true&characterEncoding=UTF-8" userId="saas1"
password="olymtech1" />
<!--把JDBC DECIMAL 和  NUMERIC 类型解析为java.math.BigDecimal. (默认false,即把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer ) -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- entity存放目录 -->
<javaModelGenerator targetPackage="com.olymtech.cs.base.datads.entiy" targetProject="base-datads" />
<!-- mapper xml存放目录 -->
<sqlMapGenerator targetPackage="config.mappers" targetProject="base-datads" />
<!-- mapper接口存放目录
<javaClientGenerator targetPackage="com.olymtech.boss.crm.dao" targetProject="com.olymtech.boss.crm" type="XMLMAPPER" />
-->
<!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等
<table schema="ProcessManagement" tableName="process_management"/>
<table schema="ProcessEmployeeRela" tableName="process_employee_rela"/> -->
<!--         <table schema="Airport" tableName="airport"/>
<table schema="Carrier" tableName="carrier"/>
<table schema="Route" tableName="route"/>
<table schema="Seaport" tableName="seaport"/> -->
<table schema="countryRouteRela" tableName="country_route_rela"/>
</context>
</generatorConfiguration>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: