1 首先eclipse需要安装一个插件

  

2 两个配置文件

1 generator.properties

  

2 generator.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>
<!-- 引用配置文件 -->
<properties resource="generator.properties" />
<classPathEntry location="${classpath}" /> <context id="module-organization-configure" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<!--去除注释 (true好像不起作用) -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator> <!--数据库连接 -->
<jdbcConnection driverClass="${driver}" connectionURL="${url}"
userId="${user}" password="${password}">
</jdbcConnection> <!-- 这个元素的配置用来指定JDBC类型和Java类型如何转换。 -->
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="true" />
</javaTypeResolver> <!-- 该元素用来控制生成的实体类 -->
<javaModelGenerator targetPackage="${package.entity}" targetProject="${project}">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="false" />
<property name="rootClass" value="org.service.core.entity.BaseEntity" />
</javaModelGenerator> <!--生成SQLMAP文件 -->
<sqlMapGenerator targetPackage="${package.mapper}" targetProject="${project}">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!--生成Dao文件 可以配置 type="XMLMAPPER"生成xml的dao实现context id="DB2Tables" 修改targetRuntime="MyBatis3" -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="${package.mapper}" targetProject="${project}">
<property name="enableSubPackages" value="true" />
<property name="rootInterface" value="org.service.core.dao.IBaseMapper" />
<property name="methodNameCalculator" value="extended" />
</javaClientGenerator> <!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等 -->
<table tableName="his_allergic_history"></table>
</context>
</generatorConfiguration>

3 自动生成

右键-->Run As -->Run Mybatis Generator

4 实例

表  

实体类

xml里按需求改改

自动生成实体类和xml的更多相关文章

  1. 使用T4为数据库自动生成实体类

    T4 (Text Template Transformation Toolkit) 是一个基于模板的代码生成器.使用T4你可以通过写一些ASP.NET-like模板,来生成C#, T-SQL, XML ...

  2. Mybatis自动生成实体类

    Maven自动生成实体类需要的jar包 一.pom.xml中 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...

  3. Springboot mybatis generate 自动生成实体类和Mapper

    https://github.com/JasmineQian/SpringDemo_2019/tree/master/mybatis Springboot让java开发变得方便,Springboot中 ...

  4. Mybatis自动生成实体类、dao接口和mapping映射文件

    由于Mybatis是一种半自动的ORM框架,它的工作主要是配置mapping映射文件,为了减少手动书写映射文件,可以利用mybatis生成器,自动生成实体类.dao接口以及它的映射文件,然后直接拷贝到 ...

  5. .net core 中简单封装Dapper.Extensions 并使用sqlsuger自动生成实体类

    引言 由公司需要使用dapper  同时支持多数据库 又需要支持实体类 又需要支持sql 还需要支持事务 所以采用了 dapper + dapperExtensions  并配套 生成实体类小工具的方 ...

  6. Asp.Net Core如何根据数据库自动生成实体类

    通过引用Nuget包添加实体类 运行 Install-Package Microsoft.EntityFrameworkCore.SqlServer 运行 Install-Package Micros ...

  7. mybatis根据表逆向自动化生成代码(自动生成实体类、mapper文件、mapper.xml文件)

    .personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...

  8. Mybatis自动生成实体类和实体映射工具

    Mybatis Mysql生成实体类 用到的Lib包: mybatis-generator-core-1.3.2.jarmysql-connector-java-5.1.30.jar 1. 创建一个文 ...

  9. NHibernate生成实体类、xml映射文件

    最近工作电脑装完win10后,之前使用的codeSmith安装不了,索性自己写一个. 界面比较简单,如下图: 第一行为Oracle数据库的连接字符串.连接成功后,填充表到第4行的下拉列表中. 第二行为 ...

随机推荐

  1. C语言在宏定义中使用语句表达式和预处理器运算符

    语句表达式的亮点在于定义复杂功能的宏.使用语句表达式来定义宏,不仅可以实现复杂的功能,而且还能避免宏定义带来的歧义和漏洞.下面以一个简单的最小值的宏为例子一步步说明. 1.灰常简单的么,使用条件运算符 ...

  2. redis学习-散列表常用命令(hash)

    redis学习-散列表常用命令(hash)   hset,hmset:给指定散列表插入一个或者多个键值对 hget,hmget:获取指定散列表一个或者多个键值对的值 hgetall:获取所欲哦键值以及 ...

  3. JAVA 8 主要新特性 ----------------(七)新时间日期 API ----- Duration “时间”间隔

    Duration:用于计算两个“时间”间隔 简介: 用法: 1.Zero常量 实例: Duration duration = Duration.ZERO; System.out.println(&qu ...

  4. IO流的种类

    字节流:InputStream(new FileInputStream(new File()); Outpustream(new FileOutputStream(new File()); 字符流:  ...

  5. AngularJS 关于ng-model和ng-bind还有{{}}

    What's the difference between ng-model and ng-bind ng-bind has one-way data binding ($scope --> v ...

  6. djangoの2

    古鸽或百度的镜子:   1、E:\django下建个文件夹名为搜索引擎→PyCharm新建项目选Django→location改为E:\django\搜索引擎→More Settings的Applic ...

  7. 转 Refresh Excel Pivot Tables Automatically Using SSIS Script Task

    Refresh Excel Pivot Tables Automatically Using SSIS Script Task https://www.mssqltips.com/sqlservert ...

  8. Linux 搜某个文件里关键字的上下500行到执行文件里

    Linux 搜某个文件里关键字的上下500行到执行文件里grep '300000111110' -C 500 ./saastom7061_APP3/logs/sass.log >/app/saa ...

  9. Hbase的常见shell操作

    1.带namespace的:https://blog.csdn.net/opensure/article/details/46470969 2.http://www.cnblogs.com/xing9 ...

  10. 笔记:安卓App消息处理机制

    内容简述 类似Binder机制,MessageQueue.Looper也有底层的C++实现,涉及文件管道和驱动等. 以下仅从Java层的Looper.Handler和MessageQueue等相关类型 ...