ideamaven版的MBG逆向工程
一、简介
简称MBG,是一个专门为MyBatis框架使用者定制的代码生成器,可以快速的根据表生成对应的映射文件,接口,以及bean类。
支持基本的增删改查,以及QBC风格的条件查询。
但是表连接、存储过程等这些复杂sql的定义需要我们手工编写
• 官方文档地址 http://www.mybatis.org/generator/
• 官方工程地址 https://github.com/mybatis/generator/releases
2.1、依赖
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
2.2添加插件: 里面还要在添加一个mysql连接驱动的依赖 。
<!--mybatis-generator-maven-plugin-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
</dependencies>
</plugin>
2.3在resources源文件夹下面创建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:/Java/lib/mysql-connector-java-5.1.43.jar" />-->
<context id="test" targetRuntime="MyBatis3"> <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
<commentGenerator>
<!-- 这个元素用来去除指定生成的注释中是否包含生成的日期 false:表示保护 -->
<!-- 如果生成日期,会造成即使修改一个字段,整个实体类所有属性都会发生变化,不利于版本控制,所以设置为true -->
<property name="suppressDate" value="true" />
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/crmpro"
userId="root"
password="ych521mm">
</jdbcConnection>
<javaTypeResolver>
<!-- This property is used to specify whether MyBatis Generator should
force the use of java.math.BigDecimal for DECIMAL and NUMERIC fields, -->
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 指定javaBean的生成策略 文件夹自己定义-->
<javaModelGenerator targetPackage="pojo"
targetProject=".\src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator> <!-- sqlMapGenerator:sql映射生成策略: -->
<sqlMapGenerator targetPackage="dao"
targetProject=".\src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!-- javaClientGenerator:指定mapper接口所在的位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="dao"
targetProject=".\src">
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <!-- 指定要逆向分析哪些表:根据表要创建javaBean -->
<table tableName="account" domainObjectName="Account"></table> <!-- 要生成哪些表 -->
<table tableName="employee" domainObjectName="Employee"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table> </context>
</generatorConfiguration>
这样就在idea搭配maven环境下完成代码的生成!!!!
ideamaven版的MBG逆向工程的更多相关文章
- Mybatis七(MBG 逆向工程)
官方地址:http://www.mybatis.org/generator/ https://github.com/mybatis/generator/releases <1>编写mbg. ...
- MyBatis_Generator (MBG)逆向工程的四种方式
mybatis是目前很流行的持久层框架,其逆向工程更是大大缩减了我们的开发时间.有兴趣的可以看文档. 文档地址: http://www.mybatis.org/generator/index.html ...
- MBG逆向工程报错:generate failed: Exception getting JDBC Driver: com.mysql.jdbc.Driver
修改pom文件,逆向工程如下: <!-- 逆向工程 --> <plugin> <groupId>org.mybatis.generator</groupId& ...
- 回顾一下MyBatis逆向工程——自动生成代码
前言 最近做的项目(SSM+Shiro)的数据库表已经创建完成,一共有15张表,如果我们一个个去写pojo/bean的代码以及各种sql语句的话未免太过麻烦而且很容易出错,这个时候我们就需要MyBat ...
- 尚硅谷SSM-CRUD实战Demo
SSM-CRUD实战项目 1. 项目总览 SpringMVC + Spring + MyBatis CRUD:增删改查 功能: 分页 数据校验 jquery前端校验+JSR303后端校验 ajax R ...
- 01_Mybaits逆向工程maven版
1.创建generatorSqlmapCustom工程 2.修改pom文件 <?xml version="1.0" encoding="UTF-8"?&g ...
- mybatis逆向工程mbg
mbg:mybatis generator=mybatis代码生成器 1.看一下项目结构 其中bean文件,mapper接口文件和mapper.xml文件是代码生成器自动生成的. 使用generato ...
- IntelliJ IDEA 2017版 spring-boot2.0.4+mybatis反向工程;mybatis+springboot逆向工程
一.搭建环境 采用IDE自动建立项目方式 然后,next next,配置导入依赖包 项目就生成了,在项目下导入配置文件GeneratorMapper.xml(项目结构如图所示) 配置文档,建立数据库和 ...
- mybatis逆向工程 mbg运行java代码时提示找不到MBG.xml的解决方法
这里要写全路径才能找到文件
随机推荐
- HDU 5687 Problem C ( 字典树前缀增删查 )
题意 : 度熊手上有一本神奇的字典,你可以在它里面做如下三个操作: 1.insert : 往神奇字典中插入一个单词 2.delete: 在神奇字典中删除所有前缀等于给定字符串的单词 3.search: ...
- 靠!老师居然叫我们去写博弈论!!!结果写了一个晚上的博弈论,简直要死QAQ。。。发发博客休息一下。。。TAT。。。
萌萌的糖果博弈 题目描述: 用糖果来引诱小朋友学习是最常用的手法,绵羊爸爸就是用糖果来引诱萌萌学习博弈的.他把糖果分成了两堆,一堆有A粒,另一堆有B粒.他让萌萌和他一起按照下面的规则取糖果:每次可以任 ...
- SpringCloud 教程 (二) 服务链路追踪(Spring Cloud Sleuth)
一.简介 Add sleuth to the classpath of a Spring Boot application (see below for Maven and Gradle exampl ...
- nginx修改默认运行80端口的方法
修改方法 很简单,修改nginx的配置文件, 对应的值,如图: 将其改为别的端口号,就可以了.
- 微信小程序image组件
image组件:是小程序专门针对图片的组件,功能强大 image组件的属性: src:类型 字符串 图片资源的路径 mode:类型 字符串 图片裁剪缩放模式 lazy-load:类型 布尔 图片的懒加 ...
- h5表单属性的介绍
表单 type属性对应的属性值 text:代表文本框 案例:<input type="text" /> password:代表密码框 radio:单选框 checkbo ...
- netflow-module
https://www.elastic.co/guide/en/logstash/current/netflow-module.html
- Ueditor1.4.4 Jsp版本视频上传成功,重新编辑时无法打开、在文本框内无法显示、html源码显示src为空
1. 编辑 ueditor.config.js 第355行 将 whitList 改为 whiteList 2.编辑ueditor.all.js 注释掉7343.7344.7345行代码,即: var ...
- java SimpleDateFormat setLenient用法
参考博客:https://www.cnblogs.com/my-king/p/4276577.html SimpleDateFormat.setLenient(true) : 默认值true,不严格解 ...
- 阶段1 语言基础+高级_1-3-Java语言高级_1-常用API_1_第8节 Math类_19_Math练习:小学数学真题
题目 画数轴 解题思路 强转成int类型就会舍弃小数位数 输出最终的数量 如果用Math.ceil的方式的话