利用mybatis插件反向生成javabean
2016-10-17 17:47
459 查看
mybatis generator 可以提高开发速度,这个插件可以自动生成代码,创建DAO层相关代码,就像利用HIbernate反相生成一样。
地址:http://pan.baidu.com/s/1c0cjDEK
(这个地址不可用的话,百度一下MyBatis_Generator下载。蛮多的)
解压得到这两个文件夹
将解压得到的文件夹里面的内容对应放入eclipse里面,重启eclipse!!
这样就安装成功了!!
generatorConfig.xml
配合powerDesigner里面的物理模型sql语句导出使用,大大提高效率。解放双手!!
简单实用,更多的时间得到释放。
首先是安装插件
1.下载、解压
文件:MyBatisGenerator地址:http://pan.baidu.com/s/1c0cjDEK
(这个地址不可用的话,百度一下MyBatis_Generator下载。蛮多的)
解压得到这两个文件夹
2.找到eclipse的安装目录
将解压得到的文件夹里面的内容对应放入eclipse里面,重启eclipse!!
3.检查是否安装成功
eclipse左侧空白处 右键New–>other–>mybatis 看有没有插件这样就安装成功了!!
数据库反向生成实体类
1.配置xml文件
官网文件说明:http://www.mybatis.org/generator/configreference/xmlconfig.htmlgeneratorConfig.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" > <!-- mybatis数据库逆向生成实体类 --> <generatorConfiguration > <!--数据库驱动jar --> <classPathEntry location="D:\MAVEN\Repositories\com\oracle\ojdbc6\11.2.0.1\ojdbc6-11.2.0.1.jar" /> <context id="context1" > <!--去除注释 --> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--数据库连接 --> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@192.168.00.000:0000:test" userId="test" password="test"> </jdbcConnection> <!-- 实体 --> <javaModelGenerator targetPackage="com.test.web.model.ocr" targetProject="bass" /> <!-- xml文件 --> <sqlMapGenerator targetPackage="com.test.web.mapping.ocr" targetProject="bass" /> <!-- dao --> <javaClientGenerator targetPackage="com.test.web.dao.ocr" targetProject="bass" type="XMLMAPPER" /> <!-- 数据库对应表格 --> <!-- <table tableName="B_IDCARD_BACK" domainObjectName="IdcardBack" /> <table tableName="B_IDCARD_FRONT" domainObjectName="IdcardFront" /> <table tableName="B_IDCARD_LEGALITY" domainObjectName="IdcardLegality" /> <table tableName="B_IDCARD_REQUEST" domainObjectName="IdcardRequest" /> --> <table tableName="B_VERIFY_ACTIVE_MEGLIVE" domainObjectName="VerifyActiveMeglive" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > </table> <table tableName="B_VERIFY_ACTIVE_MEGLIVE_RESP" domainObjectName="VerifyActiveMegliveResp" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > </table> </context> </generatorConfiguration>
2.点击文件右键–>Generate Mybatis/iBATis Artifacts
生成的文件配合powerDesigner里面的物理模型sql语句导出使用,大大提高效率。解放双手!!
去掉Mybatis Generator生成的一堆 example
mybatis generator自动生成的代码里老是有一堆example,虽然说他封装的东西比较多,但是大部分时候并不会用到。如果需要改的时候,在接口和mapper里修改便是了。<table schema="general" 4000 tableName="tb_table_name" domainObjectName="EntityName" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > <property name="useActualColumnNames" value="true"/> </table>
简单实用,更多的时间得到释放。
相关文章推荐
- java连接oracle数据库(利用MyEclipse开发工具反向生成 bean与配置文件)
- java连接oracle数据库(利用MyEclipse开发工具反向生成 bean与配置文件)
- java连接oracle数据库(利用MyEclipse开发工具反向生成 bean与配置文件)
- java连接oracle数据库(利用MyEclipse开发工具反向生成 bean与配置文件)
- 利用Mybatis-generator自动生成java-bean和dao和mapper.xml
- Mybatis插件之generatorConfig自动生成JavaBean之不使用默认的驼峰式设计字段
- 利用mybatis-gennerator插件,自动生成的所需要的dao、bean、mapper xml
- 利用反射与dom4j读取javabean生成对应XML和读取XML得到对应的javabean对象集合
- 利用Excel的vba脚本根据数据库表结构自动生成java的action,bean,dao,mode,service,xml,sql,jsp等
- mybatis反向工程生成插件使用
- 利用mybatis generator插件生成基于分页语句及分页解决方案
- 带图形界面的mybatis 反向生成工具插件
- MyBatisGenerator 自动生成java代码(反向工具)
- 利用mybatis-generator自动生成JAVA的实体类和mapping等
- AndroidStudio插件GsonFormat:根据Json自动生成JavaBean
- Mybatis分页-利用Mybatis Generator插件生成基于数据库方言的分页语句,统计记录总数
- java_model_dao_自动生成_generator-mybatis-generator-1.3.2 基于maven插件
- 利用php访问数据库数据表,生成javabean.java文件,符合javabean语法
- 用mybatis-gennerator插件自动生成mybatis所需要的dao、bean、mapper xml文件