MyBatis Generator generatorConfig.xml配置详解
所有Generator的xml详细说明见:http://mybatis.org/generator/configreference/xmlconfig.html (英文版)
引用 http://blog.csdn.net/pk490525/article/details/16819307
现在针对generatorConfig.xml配置进行解说,至于其内部元素的详解见英文文档,贴上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="init.properties"/>
- <!-- 指定数据连接驱动jar地址 -->
- <classPathEntry location="${classPath}" />
- <!-- 一个数据库一个context -->
- <context id="infoGuardian">
- <!-- 注释 -->
- <commentGenerator >
- <property name="suppressAllComments" value="false"/><!-- 是否取消注释 -->
- <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->
- </commentGenerator>
- <!-- jdbc连接 -->
- <jdbcConnection driverClass="${jdbc_driver}"
- connectionURL="${jdbc_url}" userId="${jdbc_user}"
- password="${jdbc_password}" />
- <!-- 类型转换 -->
- <javaTypeResolver>
- <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
- <property name="forceBigDecimals" value="false"/>
- </javaTypeResolver>
- <!-- 生成实体类地址 -->
- <javaModelGenerator targetPackage="com.oop.eksp.user.model"
- targetProject="${project}" >
- <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
- <property name="enableSubPackages" value="false"/>
- <!-- 是否针对string类型的字段在set的时候进行trim调用 -->
- <property name="trimStrings" value="true"/>
- </javaModelGenerator>
- <!-- 生成mapxml文件 -->
- <sqlMapGenerator targetPackage="com.oop.eksp.user.data"
- targetProject="${project}" >
- <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
- <property name="enableSubPackages" value="false" />
- </sqlMapGenerator>
- <!-- 生成mapxml对应client,也就是接口dao -->
- <javaClientGenerator targetPackage="com.oop.eksp.user.data"
- targetProject="${project}" type="XMLMAPPER" >
- <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
- <property name="enableSubPackages" value="false" />
- </javaClientGenerator>
- <!-- 配置表信息 -->
- <table schema="${jdbc_user}" tableName="s_user"
- domainObjectName="UserEntity" enableCountByExample="false"
- enableDeleteByExample="false" enableSelectByExample="false"
- enableUpdateByExample="false">
- <!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample
- 是否生成 example类 -->
- <!-- 忽略列,不生成bean 字段 -->
- <ignoreColumn column="FRED" />
- <!-- 指定列的java数据类型 -->
- <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />
- </table>
- </context>
- </generatorConfiguration>
附带上我的init.properties
- #Mybatis Generator configuration
- project = EKSP
- classPath=E:/workplace/EKSP/WebContent/WEB-INF/lib/ojdbc14.jar
- jdbc_driver = oracle.jdbc.driver.OracleDriver
- jdbc_url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
- jdbc_user=INFOGUARDIAN
- jdbc_password=info_idap132
以上是xml的配置基本情况,大家如果有什么疑问或者建议,敬请评论!
MyBatis Generator generatorConfig.xml配置详解的更多相关文章
- [转载]Mybatis Generator最完整配置详解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- mybatis generator的generatorConfig.xml配置详解
generatorConfig.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ge ...
- Mybatis Generator配置文件完整配置详解
完整的Mybatis Generator(简称MBG)的最完整配置文件,带详解,再也不用去看EN的User Guide了 可以搭配着mybatis generator的中文文档看:http://mbg ...
- 【转】Mybatis Generator最完整配置详解
本文转简书:http://www.jianshu.com/p/e09d2370b796 --> --> <!-- 自动识别数据库关键字,默认false,如果设置为true,根据Sql ...
- Mybatis Generator最完整配置详解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- Mybatis Generator 最完整配置详解
这是从CSDN找到的一篇翻译文章,尝试重新排版后转载. 1. < generatorConfiguration > 标签 1.1 可以用于加载配置项或者配置文件,在整个配置文件中就可以使用 ...
- Mybati example generatorConfig.xml 配置详解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- SpringBoot—整合log4j2入门和log4j2.xml配置详解
关注微信公众号:CodingTechWork,一起学习进步. 引言 对于一个线上程序或者服务而言,重要的是要有日志输出,这样才能方便运维.而日志的输出需要有一定的规划,如日志命名.日志大小,日志分 ...
- java web.xml配置详解(转)
源出处:java web.xml配置详解 1.常规配置:每一个站的WEB-INF下都有一个web.xml的设定文件,它提供了我们站台的配置设定. web.xml定义: .站台的名称和说明 .针对环境参 ...
随机推荐
- call, apply的用法意义以及区别是什么
call和apply没有什么大的区别,两者的作用都是:改变对象的this指向的内容. 他们的写法不同,如下: func.call(func1, var1, var2, var3); func.appl ...
- c语言:蜗牛的爬行。
main() { printf("hello,word!,第一次的c语言输出"); }
- mongoDb +Java+springboot
前言 :mongoDb 是一种比较常用的非关系数据库,文档数据库, 格式为json ,redis 有五种格式. 1. 项目中要使用,这里简单做个示例.首先是连接mongoDB,用的最多的robomon ...
- SQL中存储过程中使用事务,并且加入异常处理机制.
--存储过程中使用事务,并且加入异常处理机制. -- ============================================= CREATE PROCEDURE [dbo].[UP_ ...
- [PWA] 12. Intro to IndexedDB
Use the library indexedDB-promised. Create a database and stroe: import idb from 'idb'; // Open(db_n ...
- ORACLE功能GREATEST功能说明具体实例
1 语法 GREATEST(expr_1, expr_2, ...expr_n) 2 说明 GREATEST(expr_1, expr_2, ...expr_n ...
- 一些Linux优化方法
1. 利用栈做备胎,减少分配空间的几率,IO自己有一份缓存,如果超了就使用stack空间 2. 分散IO:代表readv,可以通过一次系统调用,将内容读到分散的缓存中,可以减少系统的系统调用
- Java基础知识强化之集合框架笔记13:Collection集合存储学生对象并遍历
1. Collection集合存储学生对象并遍历: 需求:存储自定义对象并遍历Student(name,age) 分析: (1)创建学生类 (2)创建集合对象 (3)创建学生对象 (4)把学生对象添加 ...
- SpringMVC10数据验证
/** * @NotBlank 作用在String * @NotEmpty 作用在集合上 * @NotNull 作用在基本数据类型上 * */ public class User { @NotNull ...
- Win10中英文的切换
在UAP中,涉及到中英文版本切换,在string目录下面添加资源str 读取的时候 new Windows.ApplicationModel.Resources.ResourceLoader().Ge ...