# mybatis-generator-maven-plugin
**Repository Path**: jeff_sj/mybatis-generator-maven-plugin
## Basic Information
- **Project Name**: mybatis-generator-maven-plugin
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 1
- **Created**: 2018-12-18
- **Last Updated**: 2021-11-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
第二阶段生成 service和controller
# mybatis-generator的代码自动生成工具
该插件可以使得mybatis-generator生成的代码中修改的部分可以原封不动的保留下来,如添加的新的变量,方法,注解等都会被保留。
*由于是自定义的,就限制了mybatis-generator扩展性,所有代码标准都已经统一。*
## 一. 新方式:无需任何配置文件,使用插件直接生成代码
**此方式会读取数据库中的表元数据,来自动生成全部表的mybatis代码**
corg.jeff.plugin
mybatis-generator-maven-plugin
1.0.0-SNAPSHOT
com.mysql.jdbc.Driver
jdbc:mysql://192.168.1.48:3306/turtle_warehouse
root
Sonar@1234
target
com.htdc.turtle.entity
com.htdc.turtle.mapper
target
com.htdc.turtle.mapper.xml
false
mysql
mysql-connector-java
5.1.39
**有时候,表的字段类型需要自定义,可以引入xml的方式来自动生成代码**
/**
* 采用新模式并考虑使用xml引入table时的模式。引入xml必须指定
* ONLY_TABLE 只从表中生成代码(默认)
* ONLY_XML 只从XML中生成代码
* TABLE_XML 两者都可以, 同样的table名,xml生成优先
*/
xmlTableMode
//包含table描述的xml,支持多地址,以逗号分割。当模式为ONLY_XML或者TABLE_XML时, 必须配置该变量
tableXMLConfigs
配置如下:
corg.jeff.plugin
mybatis-generator-maven-plugin
1.0.0-SNAPSHOT
TABLE_XML
${basedir}/src/main/resources/generate/a.xml
com.mysql.jdbc.Driver
jdbc:mysql://192.168.1.48:3306/turtle_warehouse
root
Sonar@1234
target
com.htdc.turtle.entity
com.htdc.turtle.mapper
target
com.htdc.turtle.mapper.xml
mysql
mysql-connector-java
5.1.39
a.xml代码如下:
**有时候表名附带特殊的前缀,可以配置去掉; 支持多字符串过滤,以逗号分割;仅在table中有效,xml配置方式会覆盖**
t_,X_
## 二. 老方式:按mybatis原生的配置方式生成代码. 不支持属性文件. 不支持自定义插件.
corg.jeff.plugin
mybatis-generator-maven-plugin
1.0.0-SNAPSHOT
true
${basedir}/src/main/resources/generate/generatorConfig.xml
mysql
mysql-connector-java
5.1.39
请在generatorConfig.xml中设置plugin如下:
## 三. 内置sql创建内存数据库的方式,兼容上面两种形式
使用配置 isGegerateCodeBySql 和sqlConfig来读取sql创建内存数据库 。注意:由于使用了H2来创建表,有些非标准语法是不支持的。
org.jeff.plugin
mybatis-generator-maven-plugin
1.0.0-SNAPSHOT
true
false
ONLY_TABLE
target
com.htdc.turtle.entity
com.htdc.turtle.mapper
target
com.htdc.turtle.mapper.xml
MyCustomPlugin
t_
true
${basedir}/src/main/resources/sql/a.sql
mysql
mysql-connector-java
5.1.39
## 四. 其他参数
false 生成实体代码时,是否屏蔽字符串的trim方法,默认不生成trim
## 开发提醒
### 使用自定义的插件,需在maven的settings.xml配置
org.jeff.plugin
### maven执行指令:
mvn codegenerate:generate
### 部署发布
mvn clean deploy -Phtdc
## git小技巧
git remote add origin-chiway http://192.168.37.168:3000/jeff/mybatis-generator-maven-plugin.git
git remote -v
git push origin
git push origin-chiway