andersonfeng-mybatis-generator-plugins

mybatis generator plugins

License

License

Categories

Categories

Github Development Tools Version Controls MyBatis Data ORM
GroupId

GroupId

io.github.andersonfeng
ArtifactId

ArtifactId

com.github.andersonfeng.mybatis-generator-plugins
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

andersonfeng-mybatis-generator-plugins
mybatis generator plugins
Project URL

Project URL

https://github.com/Andersonfeng/mybatis-generator-plugins
Source Code Management

Source Code Management

https://github.com/Andersonfeng/mybatis-generator-plugins

Download com.github.andersonfeng.mybatis-generator-plugins

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.andersonfeng/com.github.andersonfeng.mybatis-generator-plugins/ -->
<dependency>
    <groupId>io.github.andersonfeng</groupId>
    <artifactId>com.github.andersonfeng.mybatis-generator-plugins</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.andersonfeng/com.github.andersonfeng.mybatis-generator-plugins/
implementation 'io.github.andersonfeng:com.github.andersonfeng.mybatis-generator-plugins:1.1'
// https://jarcasting.com/artifacts/io.github.andersonfeng/com.github.andersonfeng.mybatis-generator-plugins/
implementation ("io.github.andersonfeng:com.github.andersonfeng.mybatis-generator-plugins:1.1")
'io.github.andersonfeng:com.github.andersonfeng.mybatis-generator-plugins:jar:1.1'
<dependency org="io.github.andersonfeng" name="com.github.andersonfeng.mybatis-generator-plugins" rev="1.1">
  <artifact name="com.github.andersonfeng.mybatis-generator-plugins" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.andersonfeng', module='com.github.andersonfeng.mybatis-generator-plugins', version='1.1')
)
libraryDependencies += "io.github.andersonfeng" % "com.github.andersonfeng.mybatis-generator-plugins" % "1.1"
[io.github.andersonfeng/com.github.andersonfeng.mybatis-generator-plugins "1.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.mybatis.generator : mybatis-generator-core jar 1.3.7
org.apache.commons : commons-lang3 jar 3.7

Project Modules

There are no modules declared in this project.

该项目是mybatis 逆向工程 generator的自定义插件

#插件

  • GeneratorSwaggerAnnotation
    • 该插件用于在使用generator同时生成swagger注解
    • 使用方法
      • 在maven build-plugins-plugin中加入依赖
            <dependency>
                <groupId>io.github.andersonfeng</groupId>
                <artifactId>com.github.andersonfeng.mybatis-generator-plugins</artifactId>
                <version>1.1</version>
            </dependency>
      • 在generatorConfig.xml中配置swagger插件
        <!--自动为entity生成swagger2文档-->
        <plugin type="com.mybatis.generator.plugins.GeneratorSwaggerAnnotation">
            <!--是否生成@apiModel注解-->
            <property name="apiModel" value="true"/>
            <!--@ApiModelProperty注解中是否需要带java属性-->
            <property name="addJavaProperty" value="true"/>
            <!--@ApiModelProperty注解中是否要带数据库字段注释-->
            <property name="addRemarks" value="true"/>
        </plugin>
      • 生成结果
        import io.swagger.annotations.ApiModel;
        import io.swagger.annotations.ApiModelProperty;
        ...
        
        @ApiModel(value="com.generator.Vote")
        @Table(name = "vt_vote")
        public class Vote {
            /**
             * 自增id
             */
            @Id
            @GeneratedValue(strategy = GenerationType.IDENTITY)
            @ApiModelProperty(value="id自增id")
            private Integer id;
  • GeneratorClassAnnotation
    • 在generatorConfig.xml中配置类注解插件
          <!--添加类注解和依赖-->
          <plugin type="com.mybatis.generator.plugins.GeneratorClassAnnotation">
              <property name="Data" value="lombok.Data"/>
              <property name="ToString" value="lombok.ToString"/>
          </plugin>
    • 生成结果
      import java.io.Serializable;
      import java.util.Date;
      import javax.persistence.*;
      import lombok.Data;
      import lombok.ToString;
      ...            
      
      @Data
      @ToString
      @Table(name = "news")
      public class TouTiaoNews implements Serializable {...}
  • GeneratorIgnoreGetter/GeneratorIgnoreSetter
    • 在generatorConfig.xml中配置类注解插件
      <!--去掉getter方法-->
      <plugin type="com.mybatis.generator.plugins.GeneratorIgnoreGetter"/>
      
      <!--去掉setter方法-->
      <plugin type="com.mybatis.generator.plugins.GeneratorIgnoreSetter"/>
    • 生成结果
      没有getter setter方法

Versions

Version
1.1
1.0