MyBatis Generator自动生成Dto、Dao、Mapping
来源:互联网 发布:什么软件可以刷机 编辑:程序博客网 时间:2024/05/22 06:50
在使用mybatis的时候我一直有个疑问,mybatis是否可以和hibernate一样自动生成一些配置文件。
在网上摸索了一段时间后我发现,MyBatis Generator就有这个功能。
1.下载mybatis-generator
百度网盘 mybatis-generator
2.下载后的文件操作
下载后解压:
将上面文件拷贝到eclipse目录
打开eclipse,File->new ->other->mybatis
我这里放到项目的bin目录下面
点击确定会创建generatorConfig.xml文件
generatorConfig.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="D:\repository\mysql\mysql-connector-java\5.1.21\mysql-connector-java-5.1.21.jar" /> <context id="context1" > <!-- 解决乱码问题 --> <commentGenerator> <property name="javaFileEncoding" value="UTF-8"/> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/wind_app" userId="root" password="root" /> <!-- pojo对象存放位置 --> <javaModelGenerator targetPackage="com.wind.model" targetProject="MyJava" /> <!-- xml文件存放位置 --> <sqlMapGenerator targetPackage="com.wind.xml" targetProject="MyJava" /> <!-- mapper对象存放位置 --> <javaClientGenerator targetPackage="com.wind.mapper" targetProject="MyJava" type="XMLMAPPER" /> <table tableName="account" /> </context></generatorConfiguration>
generatorConfig.xml上面右键可以发下如下图标,点击即可在对应项目的对应包下创建相关的model、mapper、xml文件了。
这里的一些相关配置可以查阅文档
http://generator.sturgeon.mopaas.com/index.html
如在配置中遇到错误可以留言,我们可以探讨
1 0
- MyBatis Generator自动生成Dto、Dao、Mapping
- MyBatis Generator 自动生成 Dto、Dao、Mapping
- 使用MyBatis Generator插件自动生成Dto、Dao、Mapping
- MyBatis generator (postgres)-----生成Dto、Dao、Mapping
- mybatis-generator自动生成dao、mapping、model
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- mybatis-generator自动生成dao、mapping、bean配置详解(转)
- 使用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相关
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
- 自定义cell
- 【Java并发编程实战】—–“J.U.C”:CountDownlatch
- Cuda编程总结2013-10-120:32:46
- JAVA基础(13) javaMail发送邮件设置发件人中文昵称
- 推荐!手把手教你使用Git
- MyBatis Generator自动生成Dto、Dao、Mapping
- 发送短信方法
- JavaScript另类网页特效
- php 多态与接口学习实现与实例代码
- Android 内存优化
- RAD Studio 10 Seattle 行动开发成功案例分享研讨会
- MySQL:UNIX时间戳与日期的相互转换
- 编程的智慧,带你少走弯路
- CUDA编程札记