2分钟使用mybatisGenerator自动生成dao和mapper文件——使用cmd命令行
来源:互联网 发布:nba比赛球员数据 编辑:程序博客网 时间:2024/06/07 00:16
1:下载mybatis generator 的jar包
https://github.com/mybatis/
2:撰写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="C:\ihome\jar\mysql\mysql-connector-java\5.1.37\mysql-connector-java-5.1.37.jar"/> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--数据库链接地址账号密码--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/fms" userId="root" password="huang660612317"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!--生成Model类存放位置--> <javaModelGenerator targetPackage="com.fms.intf.model" targetProject="C:\etraining\fms\fms-intf\src\main\java"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <!--生成映射文件存放位置--> <sqlMapGenerator targetPackage="config.mybatis" targetProject="C:\etraining\fms\fms-web\src\main\resources"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!--生成Dao类存放位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.fms.impl" targetProject="C:\etraining\fms\fms-service\src\main\java"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!--生成对应表及类名--> <table tableName="r_field_rule" domainObjectName="FieldRule" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context></generatorConfiguration>
classPathEntry 中的路径换成自己的路径<pre name="code" class="html">jdbcConnection 中的路径换成目的数据库的路径,以及用户名密码<pre name="code" class="html">javaModelGenerator
sqlMapGenerator
javaClientGenerator 以上三个标签分别为,生成实体类,生成mapper文件,生成dao类的配置 将目的地址进行相应的修改<pre name="code" class="html">table 对应数据库中的每张表,将表面和对应实体类名称进行相应改变即可,如果有多张表,需要使用多个table
3:执行命令
java -jar C:\ihome\jar\org\mybatis\generator\mybatis-generator-core\1.3.2\mybatis-generator-core-1.3.2.jar -configfile C:\etraining\fms\fms-web\src\main\resources\config\generatorConfig.xml -overwrite-jar 的参数为mybatis-generator-core的具体路径
-configfile 的参数为 第二步撰写的xml文件的位置
4success
MyBatis Generator finished successfully.
参考文档:
http://www.cnblogs.com/yjmyzz/p/4210554.html
https://my.oschina.net/lilw/blog/168304
0 0
- 2分钟使用mybatisGenerator自动生成dao和mapper文件——使用cmd命令行
- idea使用MybatisGenerator逆向生成DAO文件
- 使用mybatis-generator自动生成dao、model和mapper
- 使用MyBatis Generator自动生成实体、mapper和dao层
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- Mybatis自动代码生成插件MybatisGenerator使用
- 使用mybatis-generator自动生成dao/map/mapper
- mybatis自动生成mapper,dao,映射文件
- mybatis自动生成mapper,dao,映射文件
- MyBatis自动生成mapper,dao,model文件
- Mybatis使用generator自动生成mapper文件
- mybatis自动生成entity,dao和mapper
- eclipse使用MyBatisGenerator自动生成相关文件出错:project does not exist
- Mybatis--使用mybatis generator插件映射数据库,自动生成pojo对象,dao接口,mapper.xml文件的方法
- eclipse中SSM配置文件包名提醒和自动生成pojo,mapper.xml,dao接口插件的使用
- mybatis generator自动生成dao,model,mapper文件
- mybatis自动生成dao, model, mapper xml文件
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- velocity基础教程--1.标准使用
- 安卓启动引导页,很有个性的安卓启动页 可以判断是不是第一次启动
- [NOIP模拟题][高效算法设计][建模][BFS][记忆化搜索]
- css3 渐变效果
- MAVEN学习之旅
- 2分钟使用mybatisGenerator自动生成dao和mapper文件——使用cmd命令行
- Jquery选择器的基本选择器
- 关于eventbus报错its super classes have no public methods with the @Subscribe的问题
- android基础_第三天
- MAC 新建文本文档
- 架构师需要了解的Paxos原理、历程及实战
- 对封装、继承、多态、抽象的理解
- 解决Apache 2.4.9提示You don’t have permission to access / on this server.
- Java初级学习小记-重载和this关键字及static关键字