All Projects → maihaoche → mybatis-generator-plugin

maihaoche / mybatis-generator-plugin

Licence: other
MyBatis 生成模板代码的逻辑以插件的形式部署

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to mybatis-generator-plugin

gitlab-quickmr-idea-plugin
IntelliJ IDEA plug-in that will help you to quickly create Merge Requests for GitLab
Stars: ✭ 17 (-32%)
Mutual labels:  intellij-plugin, intellij-idea
IDEAPractice
Java练习 - Java基础知识,面试题,小demo,长期积累 | intellij idea + maven + tomcat
Stars: ✭ 45 (+80%)
Mutual labels:  mybatis, intellij-idea
Mybatis Log Plugin
Restore mybatis sql log to original whole executable sql.
Stars: ✭ 318 (+1172%)
Mutual labels:  intellij-plugin, mybatis
xmake-idea
🍨 A XMake integration in IntelliJ IDEA
Stars: ✭ 44 (+76%)
Mutual labels:  intellij-plugin, intellij-idea
intellij-treeInfotip
IDEA项目结构树中的节点添加显示自定义备注文本IDEA DirectoryNode adds custom text for display
Stars: ✭ 48 (+92%)
Mutual labels:  intellij-plugin, intellij-idea
Intellij Mybaitslog
用于在IDEA将Mybatis的SQL日志还原为可执行的SQL,Used to restore Mybatis SQL logs to executable SQL in IDEA,
Stars: ✭ 501 (+1904%)
Mutual labels:  intellij-plugin, mybatis
Mybatiscodehelper Pro
brucege.com
Stars: ✭ 1,565 (+6160%)
Mutual labels:  intellij-plugin, mybatis
SideMirror
An Android Studio plugin to mirror your android devices with scrcpy directly from Android Studio.
Stars: ✭ 49 (+96%)
Mutual labels:  intellij-plugin, intellij-idea
idea-return-highlighter
Highlight return keywords.
Stars: ✭ 24 (-4%)
Mutual labels:  intellij-plugin, intellij-idea
gradle-dependencies-plugins-helper-plugin
This is an IntelliJ IDEA plugin for searching dependencies/plugins from JCentral/GradlePlugins inside Gradle projects.
Stars: ✭ 33 (+32%)
Mutual labels:  intellij-plugin, intellij-idea
intellij-frege
IntelliJ IDEA plugin for Frege language
Stars: ✭ 34 (+36%)
Mutual labels:  intellij-plugin, intellij-idea
springbook
java8+springMVC4+mybatis编写一个图书管理系统
Stars: ✭ 32 (+28%)
Mutual labels:  mybatis, intellij-idea
Squaretest
Tracks issues for the Squaretest plugin for IntelliJ IDEA
Stars: ✭ 32 (+28%)
Mutual labels:  intellij-plugin, intellij-idea
IntelliJ-IDEA-Translate2Chinese
Chinese ​(Simplified)​ Language Pack EAP v201.15 魔改进行中...
Stars: ✭ 14 (-44%)
Mutual labels:  intellij-plugin
nocalhost-intellij-plugin
Nocalhost is Cloud Native Dev Environment. Provides nocalhost to help connect IntelliJ IDE and Kubernetes smoothly.
Stars: ✭ 16 (-36%)
Mutual labels:  intellij-plugin
intellij-ui-test-robot
The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.
Stars: ✭ 60 (+140%)
Mutual labels:  intellij-plugin
aemtools
AEM Tools is Intellij IDEA plugin containing Adobe Experience Manager related features
Stars: ✭ 49 (+96%)
Mutual labels:  intellij-plugin
mayday
mayday博客系统,基于springboot、mybatis、ehcache、thymeleaf、bootstrap做的博客系统,完美自适应,支持markdown编辑器
Stars: ✭ 113 (+352%)
Mutual labels:  mybatis
idea-carbon-now-sh
IntelliJ IDEA plugin to open the selected code in https://carbon.now.sh
Stars: ✭ 27 (+8%)
Mutual labels:  intellij-plugin
interstellar
Dark editor theme for JetBrains IDEs
Stars: ✭ 26 (+4%)
Mutual labels:  intellij-plugin

MyBatisGeneratorPlugin

MaiHaoChe

需求

现在团队内部有一套代码,能够根据数据库表结构直接生成一系列对象,实现基本的增删改查API,便于直接在业务逻辑中使用。这套代码目前处于游离状态(哪里需要复制粘贴到哪里),又不便于组织成jar包,作为各个项目的依赖(因为这是一套工具代码,与项目无关),这样非常不便于维护升级。 Intellij Idea 插件是最适合实现这种工具需求。既便于团队内共享,又便于统一管理并维护升级。

使用

  • 安装:在IntelliJ 的插件安装页面点击"Browse reposities...",在弹窗中搜索"mybatisgenerator"

  • 入口:安装并重启后,在菜单栏Tools下可以看到插件的功能入口

  • 配置:需要配置用于连接到目标数据库的链接,用户名和密码以及生成的各个java类和xml文件的路径。卖好车内部使用,请在"是否用于卖好车内部代码"出选择"是。

  • 生成mybatis代码:输入表名,点击确定,生成该表的mybatis代码。

实现

配置流程
  1. 配置数据库连接链接,用户名,密码,配置生成代码的目录路径;

  2. 插件连接到数据库,获取表结构信息(不获取表内容信息);

  3. 通过Velocity ,将预先定义好的模板于数据库信息结合,生成类文件,写入目标路径中。

API
  • 实体 DO,Query,Mapper,Manager, Mapper.xml。前缀为:表名(驼峰),比如表table_user,生成的实体分别为:TableUserDO,TableUserQuery,TableUserMapper,TableUserManager 和 TableUserMapper.xml。
  • DO 表对象,每个字段代表一个列
  • Query 查询对象,用于添加各类查询条件
  • Mapper mybatis 需要的mapper的接口
  • Manager 对外输出的API,包含了基本的增删改查
  • Mapper.xml mybatis的mapper文件,sql的具体实现
  • 拓展 每个对象都可以创建一个子对象,包含在同级目录的ext子目录下。具体的实现可以自定义。

  • CodeExample

public class example {

    @Autowired
    private UserManager userManager;

    public void findUser() {
        //select DO by id
        long userId = 1;
        UserDO userDOById = userManager.selectByPrimaryKey(userId);

        //select DO by query
        UserQuery userQuery = new UserQuery();
        userQuery.createCriteria()
                .andUserNameLike("JonSnow%");
        List<UserDO> userListResult = userManager.selectByQuery(userQuery);

        //select DO by page
        UserQuery pageQuery = new UserQuery();
        pageQuery.setPageNo(1);
        pageQuery.setPageSize(20);
        pageQuery.createCriteria()
                .andUserNameLike("JonSnow%");
        PageResult<UserDO> userPageResult = userManager.selectByQueryWithPage(pageQuery);
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].