MyBatis Generator 自动生成代码
来源:互联网 发布:网络吹空调 编辑:程序博客网 时间:2024/04/30 12:56
利用MyBatis Generator 可快速高效生成,Dao,mapper.xml ,实体类以及实体类对应的Example 实类。
关于 MyBatis Generator 来快速实现代码生成,可利用Eclipse装插件,插件下载地址(http://download.csdn.net/download/sinat_27406925/9996352),把里面的文件的jar包复制到eclipse对应的jar包里面,然后重启eclipse,然后按住项目右键 new—>other 找Mybatis 即可,再就是配置generator.xml。
还是来看看怎么配置 generator.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> <!-- 数据库驱动包位置 --> <!-- D:\maven\repository\mysql\mysql-connector-java\5.1.32\mysql-connector-java-5.1.32.jar--> <classPathEntry location="D:\maven\repository\mysql\mysql-connector-java\5.1.32\mysql-connector-java-5.1.32.jar" /> <context id="context1"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!-- 数据库链接URL、用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://数据库地址(自己改):3307/数据库名(自己改)" userId="用户名(自己改)" password="密码(自己改)" /> <!-- 生成模型的包名和位置 --> <javaModelGenerator targetPackage="com.epipe.user.dal.db.po" targetProject="user-impl/src/main/java" /> <!-- 生成的映射文件报名和位置 --> <sqlMapGenerator targetPackage="com.mapping" targetProject="user-impl/src/main/resources" /> <!-- 生成DAO的包名和位置 --> <javaClientGenerator targetPackage="com.epipe.user.dal.db.mapper" targetProject="user-impl/src/main/java" type="XMLMAPPER" /> <!-- 要生成的那些表(更改tableName 和domainObjectName 就可以了) --> <!-- <table schema="ssm1" tableName="FILMINFO" domainObjectName="FilmInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <columnOverride column="FILMID" property="FILMID" /> <columnOverride column="FILMNAME" property="FILMNAME" /> <columnOverride column="TYPEID" property="TYPEID" /> <columnOverride column="ACTOR" property="ACTOR" /> <columnOverride column="DIRECTOR" property="DIRECTOR" /> <columnOverride column="TICKETPRICE" property="TICKETPRICE" /> </table> --> <!-- domainObjectName="myuser" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true" 当这些为true时 生成对应的实体类的Example类,如果不想要这些Example类,可以将true 改为false即可 ---> <table tableName="sys_user" domainObjectName="myuser" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"> <columnOverride column="TYPEID" property="TYPEID" /> <columnOverride column="TYPENAME" property="TYPENAME" /> </table> </context> </generatorConfiguration>
这就是运行后生成的代码。
阅读全文
0 0
- Generator-Mybatis自动生成代码
- MyBatis Generator自动生成代码
- mybatis-generator自动生成代码
- mybatis自动生成代码generator
- MyBatis Generator 自动生成代码
- Mybatis-Generator自动生成代码
- MyBatis-generator 自动生成代码
- mybatis-generator自动生成代码
- mybatis-generator【mybatis代码自动生成】
- MBG(MyBatis Generator):MyBatis自动代码生成;
- mybatis mybatis-generator 代码自动生成工具
- 使用MyBatis-generator 自动生成MyBatis代码
- mybatis mybatis-generator 代码自动生成工具
- MyBatis使用Generator自动生成代码
- MyBatis使用Generator自动生成代码
- 用mybatis generator自动生成代码
- 使用MyBatis generator自动生成代码
- maven + MyBatis Generator 自动生成代码配置
- springboot的application.properties配置
- 误删数据库表的解决办法
- Xamarin.forms:(Rg.Plugins.Popup)Nuget包的使用小案例
- iOS 的更新提醒教程
- 美团SQL优化工具SQLAdvisor
- MyBatis Generator 自动生成代码
- vue之请求方法--axios
- 欧几里德&&扩展欧几里德详解
- 单机版延时队列
- 简述JDK的安装配置
- VMware下安装CentOS-7-x86_64-Minimal
- 关于实现Comparable接口重写compareTo方法报错问题
- SVN 撤回(回滚)提交的代码
- FFmpeg在android上多媒体编程