自动生成mybatis的model,mapper,xml工具的使用
2017-02-18 15:05
585 查看
首先把这三个文件放到一个目录里,我是放到了C盘下的wangbo目录下:
接下来就是设置config.xml文件了,config.xml:
下面解释下需要配置的地方:
配置完后打开cmd命令行,进入到配置文件所在的目录下,执行命令就好了:
命令:java -jar mybatis-generator-core-1.3.2.jar -configfile config.xml -overwrite
接下来就生成好了test包:
接下来就是设置config.xml文件了,config.xml:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE generatorConfiguration 3 PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" 4 "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> 5 <generatorConfiguration> 6 <!-- 数据库驱动--> 7 <classPathEntry location="ojdbc14.jar"/> 8 <!--修改targetRuntime="MyBatis3"--> 9 <context id="DB2Tables" targetRuntime="MyBatis3"> 10 <commentGenerator> 11 <property name="suppressDate" value="true"/> 12 <!-- 是否去除自动生成的注释 true:是 : false:否 --> 13 <property name="suppressAllComments" value="true"/> 14 </commentGenerator> 15 <!--数据库链接URL,用户名、密码 --> 16 <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:ORADB" userId="xxxxxx" password="xxxxxxxxxxxxxxxxxxx"> 17 </jdbcConnection> 18 <javaTypeResolver> 19 <property name="forceBigDecimals" value="false"/> 20 </javaTypeResolver> 21 <!-- 生成模型的包名和位置--> 22 <javaModelGenerator targetPackage="test.model" targetProject="C:\wangbo\"> 23 <property name="enableSubPackages" value="true"/> 24 <property name="trimStrings" value="true"/> 25 </javaModelGenerator> 26 <!-- 生成映射文件的包名和位置--> 27 <sqlMapGenerator targetPackage="test.mapping" targetProject="C:\wangbo\"> 28 <property name="enableSubPackages" value="false"/> 29 </sqlMapGenerator> 30 <!-- 生成DAO的包名和位置 type="XMLMAPPER"--> 31 <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao" targetProject="C:\wangbo\"> 32 <property name="enableSubPackages" value="true"/> 33 </javaClientGenerator> 34 35 <!-- 要生成哪些表--> 36 <table tableName="XLW_USER_BRANCH" domainObjectName="UserBranch" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> 37 </context> 38 </generatorConfiguration>
下面解释下需要配置的地方:
配置完后打开cmd命令行,进入到配置文件所在的目录下,执行命令就好了:
命令:java -jar mybatis-generator-core-1.3.2.jar -configfile config.xml -overwrite
接下来就生成好了test包:
相关文章推荐
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- [瞎折腾]使用freemarker编写MyBatis的Mapper.xml自动生成工具
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- [瞎折腾]使用freemarker编写MyBatis的Mapper.xml自动生成工具
- 使用Mybatis提供的mybatis generator来自动生成model/mapper.java/mapper.xml
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- mybatis使用---利用mybatis-generator自动生成mapper、model、mapper.xml
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- ssm项目使用mybatis-generator工具自动生成实体类、*mapper.xml、dao层方法
- 使用generator自动生成mybatis model、mapper.xml、mapper等(转)
- spring上使用mybatis快速生成插件快速生成xml、model、mapper
- 使用mybatis-generator自动生成dao、model和mapper
- 使用Abator自动生成ibatis的DAO.Model.mapper.xml方法使用说明
- mac下 mybatis-generator命令行方式自动生成mapper、model、xml
- mybatis自动生成mapper.xml和接口实体类工具
- 使用Mybatis-Generator自动生成Model、Mapper相关文件
- 使用mybatis自动生成Dao,Mapper.xml,Entity
- 【mybatis】根据model自动生成 mapper service dao 层的工具类