Skip to content
/ mybatis Public

Mybatis training, such as common operation, paging, Mybatis Plus, generator etc.

License

Notifications You must be signed in to change notification settings

denvie/mybatis

Repository files navigation

介绍

Mybatis training, such as common operation, paging, Mybatis Plus, generator etc.

核心模块

  • mybatis-generator

基于mybatis-generator实现根据数据库表自动生成对应的Entity、Mapper、Service、ServiceImpl、Controller、映射文件,通过自定义CommentGenerator以及PluginAdapter自动生成Java文件的版权信息、类注释、属性注释、方法注释等。

  • mybatis-plus-generator

基于mybatis-plus-generator实现根据数据库表自动生成对应的Entity、Mapper、Service、ServiceImpl、Controller等,支持通过配置文件定制多个模块的代码生成策略。配置类参考MpGeneratorConfig,配置文件参考generatorConfig.yml,示例如下:

# 基础配置
basic:
  copyright: Copyright © 2020-2020 尛飛俠(Denvie) All rights reserved.
  author: Denvie
  fileOverride: false
  open: false
  enableCache: true
  baseResultMap: true
  baseColumnList: true
  idType: ASSIGN_ID
  swagger2: false
  mapperSuffix: Mapper
  parentPackage: cn.denvie.mybatis.plus
  entityPackage: domain.entity
  mapperPackage: mapper
  servicePackage: service
  serviceImplPackage: service.impl
  controllerPackage: controller

# JDBC配置
jdbc:
  dbType: mysql
  url: jdbc:mysql://host.docker.internal:3306/mybatis-plus?serverTimezone=GMT%2B8&useSSL=true&useUnicode=true&characterEncoding=UTF-8
  driverName: com.mysql.cj.jdbc.Driver
  username: root
  password: root

# 表策略配置
table:
  entityLombokModel: true
  versionFieldName: lockVersion
  logicDeleteFieldName: deleted
  entityTableFieldAnnotationEnable: true
  restControllerStyle: true
  controllerMappingHyphenStyle: true
  entitySerialVersionUID: false
  superEntityClass: cn.denvie.mybatis.plus.base.BaseEntity
  superEntityColumns: gmt_create, gmt_modified, lock_version, deleted
  tableFillVoList:
    - fieldName: gmtCreate
      fieldFill: INSERT
    - fieldName: gmtModified
      fieldFill: UPDATE

# 业务模块配置
modules:
  - moduleName: app
    modulePath: mybatis-plus-generator
    include: tbl_user, tbl_student, tbl_class
    tablePrefix: tbl_

参考资料

About

Mybatis training, such as common operation, paging, Mybatis Plus, generator etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published