generator 生成dao model代码
来源:互联网 发布:ip的数据报文格式 编辑:程序博客网 时间:2024/05/16 00:38
利用generator 本地生成model ,dao
下载generator
配置generator-config.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> <!-- 数据库驱动包位置 --> <classPathEntry location="E:\generator\mysql-connector-java-5.1.34.jar" /> <!-- <classPathEntry location="C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar" />--> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <!-- 数据库链接URL、用户名、密砿--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbcUrl" userId="帐号名" password="密码"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成模型的包名和位置 model的包名和位置--> <javaModelGenerator targetPackage="com.xxx.xxx.model" targetProject="E:\generator\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成的映射文件包名和位置 mapper.xml包名和位置--> <sqlMapGenerator targetPackage="com.xxx.xxx.dao" targetProject="E:\generator\src"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成DAO的包名和位置 mapper.java包名和位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.xxx.xxx.dao" targetProject="E:\generator\src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成那些表(更改tableName和domainObjectName就可仿 --> <table tableName="表明" domainObjectName="model名" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" /> </context></generatorConfiguration>
其中
1.trimStrings 是否对数据库查询结果进行trim操作,如果设置为true就会生成类似这
public void setUsername(String username) {this.username = username == null ? null : username.trim();
默认为false
2.enableSubPackages设置为true,使用targetProject的路径存放
在当前目录cmd 输入
java -jar mybatis-generator-core-1.3.2.jar -configfile generator-config.xml -overwrite
successfully表示生成成功,查看targetProject目录
可以看到dao和model里面有所需的代码
阅读全文
0 0
- generator 生成dao model代码
- mybatis-generator生成model和dao层代码
- mybatis-generator生成model和dao层代码
- mybatis-generator自动生成dao、mapping、model
- mybaits generator自动生成model、xml、dao
- mybatis generator自动生成model、dao、mapper
- mybatis自定义代码生成器(Generator)——自动生成model&dao代码
- 【java项目实践】在eclipse中使用利用mybatis-generator自动生成Model、Dao、mapping代码
- SSM框架——使用 MyBatis Generator 生成代码,包括:Model、Dao、Mapping
- MySQL下MyBatis通过Generator生成Dao和Model类
- mybatis generator自动生成model、dao、mapper示例
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- selenium使用chrome时,报错ignore certificate errors
- OC中NSString 的常用方法
- Unity Mathf 数学运算(C#)
- <Android APK签名验签>二:META-INF文件分析
- 数据库备份的几种类型
- generator 生成dao model代码
- linux 开发板设置 root登录 和 登录后启动自定义应用程序
- 【问题记录】常用IDE快捷键积累
- 第4节-Linux磁盘分区规划
- Linux基础
- CSS3实现鼠标移动到图片上图片变大(缓慢变大,有过渡效果,放大的过程是有动画过渡的,这个过渡的时间可以自定义)
- Xcode打包ipa的基本步骤
- 机器学习基石 3.4 Learning with Different Input Space
- 138-Copy List with Random Pointer