ibit-mybatis-generator


License

License

Categories

Categories

MyBatis Data ORM
GroupId

GroupId

tech.ibit
ArtifactId

ArtifactId

ibit-mybatis-generator
Last Version

Last Version

2.3
Release Date

Release Date

Type

Type

jar
Description

Description

ibit-mybatis-generator
ibit-mybatis-generator
Project URL

Project URL

https://github.com/ibit-tech/ibit-mybatis-generator
Project Organization

Project Organization

IBIT程序猿
Source Code Management

Source Code Management

https://github.com/ibit-tech/ibit-mybatis-generator

Download ibit-mybatis-generator

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
tech.ibit : ibit-mybatis jar 2.1
commons-lang : commons-lang jar 2.6
commons-io : commons-io jar 2.4

runtime (1)

Group / Artifact Type Version
mysql : mysql-connector-java jar 8.0.16

Project Modules

There are no modules declared in this project.

ibit-mybatis-generator

用法

相关引用

Gradle

compile 'tech.ibit:ibit-mybatis-generator:2.x'

Maven

<dependency>
  <groupId>tech.ibit</groupId>
  <artifactId>ibit-mybatis-generator</artifactId>
  <version>2.x</version>
</dependency>

代码示例

public void test() {

    String driverName = "com.mysql.jdbc.Driver";

    // 设置jdbc路径
    String jdbcURL = "jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true";
    String username = "**";
    String password = "**";

    // 指定表明
    String[] tables = new String[]{
            "organization",
            "user",
            "user_login_record"
    };

    Generator generator = new Generator(driverName, jdbcURL, username, password, StringUtils.join(tables, ","));

    // 指定基本包路径
    String projectDir = "./";
    String basePackage = "tech.ibit.mybatis.generator.demo";
    generator.setDefaultProject(new ProjectInfo(projectDir, basePackage));

    // 指定作者
    generator.setAuthor("IBIT程序猿");

    // 设置生成所有类型文件,Mapper, Dao, Entity
    generator.setWithAll();
    
    // 是否覆盖(false:文件已经存在,则不覆盖)
    generator.setOverride(true);

    // generator.setWithEntity(); // 设置只生成Entity
    // generator.setWithMapper(); // 设置只生成Mapper文件

    // generator.setEntityProject(); // 可以单独设置entity项目路径
    // generator.setMapperProject(); // 可以单独设置mapper项目路径

    generator.generateFiles();

}

不足地方需要改进

  • 目前mysql支持得比较好,其他数据库待验证
  • 需要做成插件的方式,这样更加方便生成模板代码

Versions

Version
2.3
2.2
2.1
2.0
1.1
1.0