Eclipse使用Mybatis Generator生成pojo对象、mapper接口和mapper.xml文件
来源:互联网 发布:上帝会掷骰子知乎 编辑:程序博客网 时间:2024/06/05 07:36
下载插件:
第一步:下载mybatis.generator插件
org.mybatis.generator.eclipse.site-1.3.5.201609070108.zip,下载地址:https://github.com/mybatis/generator/releases
同时,在pom.xml中添加mybatis-generator-1.3.5.zip的依赖,如果没有使用maven,则下载这个jar包然后放到lib中。
第二部:将插件解压后,分别将plugins和fetures包下的文件全部copy到Eclipse对应的目录下。
在eclipse中使用(有一种是比较原始的方法是下载jar包后使用cmd命令提示符去生成,不仅复杂,而且总是报错,所以别浪费时间,直接在eclipse中使用):
第三部:在eclipse-》file-》new->other,创建mybatis.generator的配置文件
配置文件内容如下:
<?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>
<!-- 数据库驱动 注意:这个 location要指明\mysql-connector-java jar包的绝对路径-->
<classPathEntry location="D:\administrator\.m2\repository\mysql\mysql-connector-java\5.1.40\mysql-connector-java-5.1.40.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码(我的数据库密码为空) -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/testmavenssm" userId="root" password="">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置 这个targetProject一定不要写错:这里应该是写你的工程名字-->
<javaModelGenerator targetPackage="com.zhh.pojo" targetProject="TestMavenSSM">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="com.zhh.mapping" targetProject="TestMavenSSM">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.zhh.dao" targetProject="TestMavenSSM">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="user_t" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
最后,执行生成文件操作:
最后发现,在不同包目录下,自动生成了pojo对象和mapper类和mapper.xml文件
这样就成功了。
- Eclipse使用Mybatis Generator生成pojo对象、mapper接口和mapper.xml文件
- Mybatis--使用mybatis generator插件映射数据库,自动生成pojo对象,dao接口,mapper.xml文件的方法
- doMoreDoBetter利用mybatis生成pojo、mapper接口、mapper XML文件
- MyBatis-使用mybatis-generator-core.jar生成POJO和Mapper文件
- MyBatis-自动生成pojo、mapper和mapper.xml
- 使用MyBatis Generator生成xml,Mapper
- 关于mybatis generator.xml逆向生成mapper,pojo类,及接口
- Maven使用Mybatis Generator插件生成Mapper接口 xml和实体
- Mybatis使用generator自动生成mapper文件
- 使用Mybatis-Generator逆向生成po,映射文件和mapper接口
- 使用Mybatis-Generator自动生成Dao、model和mapper.xml相关文件
- 用IDEA基于maven项目使用mybatis-generator-plugin生成mapper和pojo
- 用IDEA基于maven项目使用mybatis-generator-plugin生成mapper和pojo
- Maven项目使用MyBatis Generator插件生成POJO和Mapper代码
- eclipse中SSM配置文件包名提醒和自动生成pojo,mapper.xml,dao接口插件的使用
- 使用mybatis-generator-core生成MyBatis Mapper文件
- mybatis使用---利用mybatis-generator自动生成mapper、model、mapper.xml
- 使用Mybatis提供的mybatis generator来自动生成model/mapper.java/mapper.xml
- 变量、内存属性、作用域、生命期
- 如何用AngularJS构建管理后台
- liunx查看tomcat 版本,重启tomcat 及查看日志
- MySQL免解压遇到的一些问题
- 输入和输出
- Eclipse使用Mybatis Generator生成pojo对象、mapper接口和mapper.xml文件
- JavaScript-01----包装对象、比较、隐式转化、类型检测
- 欢迎使用CSDN-markdown编辑器
- 基于Nodejs生态圈的TypeScript+React开发入门教程
- JPEG压缩原理与DCT离散余弦变换
- Java四类八种基本数据类型
- Java并发编程:Callable、Future和FutureTask
- P1460 健康的荷斯坦奶牛 Healthy Holsteins
- 记录Gerrit的使用