eclipse集成mybatis的generater插件
2023-09-11 14:18:56 时间
mybatis也能方向生成代码,能方向生成实体类(po)、mapper接口和Mapper接口映射文件,能减少我们代码的工作量。详细步骤如下
1、下载mybatis生成架包工具MyBatis_Generator_1.3.1.zip,解压架包把features、plugins文件夹下的架包分别拷贝到eclipse安装目录下的features、plugins文件夹。重启eclipse就行。
解压后图片如下:
Eclipse路径如图:
拷贝替换如图:
2、创建generatorConfig.xml文件,安装好mybatis 就能创建generatorConfig.xml
3、配置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:\maven\repository\org\postgresql\postgresql\9.3-1103-jdbc41\postgresql-9.3-1103-jdbc41.jar" /> <context id="context1"> <commentGenerator> <property name="suppressAllComments" value="true" /><!-- 是否取消注释 --> <property name="suppressDate" value="false" /> <!-- 是否生成注释代时间戳 --> </commentGenerator> <jdbcConnection driverClass="org.postgresql.Driver" connectionURL="jdbc:postgresql://192.168.1.1:14132/dev" userId="userId" password="password" /> <!-- targetPackage是目标包名, targetProject是包所在的位置--> <!-- javaModelGenerator生成的是实体类, sqlMapGenerator生成的是映射文件, javaClientGenerator生成的是dao --> <javaModelGenerator targetPackage="auto.dto" targetProject="testProject\src\main\java" /> <sqlMapGenerator targetPackage="auto.xml" targetProject="testProject\src\main\java" /> <javaClientGenerator targetPackage="auto.dao" targetProject="testProject\src\main\java" type="XMLMAPPER" /> <!-- domainObjectName是表对应的实体类名, tableName是对应的表名--> <!-- table可以配置多个,enable*几个参数是为了自动生成一些额外的sql操作,可以关闭--> <table domainObjectName="StudentInfoDto" tableName="student_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> <table domainObjectName="TeacherInfoDto" tableName="teacher_info" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> </table> </context> </generatorConfiguration>
4、右击generatorConfig.xml 点击Generate MyBatis/iBATIS Artifacts 生成对应接口、接口映射文件、实体类
5、查看结果
相关文章
- jmeter 性能测试与 influxdb2 集成显示监控结果
- flink针对hadoop 3.x的支持及集成方式
- Springboot集成分页插件PageHelper
- 集成学习Ensemble learning
- SpringBoot集成Activiti(三)
- 如何解决Eclipse集成华为AGC SDK工具包运行失败问题
- 教你轻松集成华为Image Kit图文排版功能
- Eclipse集成ijkplayer并实现本地和网络视频播放等
- SpringBoot集成SpringCloud
- Spring Boot 2 实战:集成 MapStruct 类型转换神器
- 【EJB学习笔记】——EJB开发环境搭建(Eclipse集成JBoss)
- 【Redis入门笔记 05】Jedis 简介 & SpringBoot 集成
- Spring Cloud :Gateway 集成 Sentinel (六)
- Spider Studio 数据挖掘集成开发环境
- 如何解决Eclipse集成华为AGC SDK工具包运行失败问题
- HttpClientFacotry Part 4: 集成 Polly 处理瞬时失效
- iOS - 集成Bundle资源文件包
- SolrCloud之分布式索引及与Zookeeper的集成--转载