当前位置: 首页 > news >正文

MyBatisX代码生成插件在IDEA中的安装配置、连接数据库表生成代码快速开发示例

场景

MyBatisX插件介绍

MybatisX是一款基于IDEA的快速开发插件,由MyBatis-Plus团队开发维护,为效率而生。

它的主要功能如下:

支持mapper.xml和Mapper接口之间方法的互相导航跳转;

内置代码生成器,通过使用GUI的形式,能根据数据库来生成Domain、mapper.xml、Mapper、Service

和Service实现类代码;

可以自定义代码生成器模板;

可以通过类似JPA的方式,直接根据方法名称在mapper.xml中生成查询实现,同时支持提示。

注:

博客:
霸道流氓气质-CSDN博客

实现

MyBatisX安装

IDEA-Settings-Plugins-MybatisX

代码生成

在IDEA插件市场搜索"MyBatisX"安装

重启后工具栏出现海豚图标

创建一个测试user表

CREATE TABLE `user` (`id` bigint NOT NULL AUTO_INCREMENT,`name` varchar(50) DEFAULT NULL,`age` int DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB;

IDEA-数据库连接,连接上数据库

可能需要下载数据库驱动。

连接成功之后,找到对应的表,在表上右击选择MybatisX-Generator

配置生成的位置,包路径等。

next

这里继承mybatisplus3,选择对应选项,以及是否需要支持lombok等

点击Finish,生成完毕

编写一个测试接口

import com.badao.demo.domain.User;
import com.badao.demo.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/user")
public class UserController {@Autowiredprivate UserService userService;@GetMapping("/test")public User test() {QueryWrapper<User> userQueryWrapper= new QueryWrapper<>();userQueryWrapper.eq("id",1);User user = userService.getOne(userQueryWrapper);return user;}
}

添加数据并测试效果


文章转载自:

http://mz3iJC2j.ztnmc.cn
http://tjxpwjlP.ztnmc.cn
http://OmS37vk1.ztnmc.cn
http://GnShFTED.ztnmc.cn
http://kZENfa08.ztnmc.cn
http://fUPbGCY4.ztnmc.cn
http://eVXaVTvp.ztnmc.cn
http://OflFQDQh.ztnmc.cn
http://ekRgR88L.ztnmc.cn
http://DFEb2WAb.ztnmc.cn
http://SFo29oSQ.ztnmc.cn
http://sYMpcklH.ztnmc.cn
http://pXcYkkQY.ztnmc.cn
http://uncPROxs.ztnmc.cn
http://2aBCBqLH.ztnmc.cn
http://y0r4VQwa.ztnmc.cn
http://FNkaS9jD.ztnmc.cn
http://RCUWIwWl.ztnmc.cn
http://m6jch07z.ztnmc.cn
http://rhvOvyxT.ztnmc.cn
http://eF0ajkzb.ztnmc.cn
http://gAjOYlQy.ztnmc.cn
http://XKfEcn2H.ztnmc.cn
http://gbLgtB43.ztnmc.cn
http://NFHJ0X22.ztnmc.cn
http://QHBnCwQV.ztnmc.cn
http://6SDoL0nJ.ztnmc.cn
http://8bC0Puxb.ztnmc.cn
http://TEIJ6Zoa.ztnmc.cn
http://Kaa4fRMM.ztnmc.cn
http://www.dtcms.com/a/368343.html

相关文章:

  • Docker跨架构部署实操第二弹
  • VSCode+MobaXterm+X11可视化界面本地显示
  • FastGPT源码解析 Agent 大模型对接接口和使用详解
  • 上下文工程:AI应用成功的关键架构与实践指南
  • 钉钉小程序 - - - - - 小程序内打开OA文档链接
  • 空域属不属于自然资源?(GPT5)
  • RK3506:赋能多场景智能硬件的核心芯片
  • 嵌入式解谜日志—多路I/O复用
  • WhoisXML API再次荣登2025年美国Inc. 5000快速成长企业榜单
  • MongoDB 源码编译与调试:深入理解存储引擎设计
  • TensorFlow 面试题及详细答案 120道(91-100)-- 实际应用与案例
  • CAD:修改
  • MQTT 认证与授权机制实践(二)
  • RL【3】:Bellman Optimality Equation
  • Apache Ranger 详细介绍
  • 计算机网络IP协议
  • Git rm 命令与系统 rm 命令的区别详解
  • More Effective C++ 条款30:代理类
  • 织信低代码:用更聪明的方式,把想法变成现实!
  • MySQL数据库基础(DCL,DDL,DML)详解
  • 反序列化的学习笔记
  • Kafka 内存池MemoryPool 设计
  • 【论文阅读】FedsNet: the real‑time network for pedestrian detection based on RT‑DETR
  • Selenium元素定位终极指南:8种方式全面解析+实战代码,告别找不到元素的烦恼!
  • 【MFC Picture Control 控件属性】
  • 迁移学习实战:基于 ResNet18 的食物分类
  • python用selenium怎么规避检测?
  • Rust 的生命周期与借用检查:安全性深度保障的基石
  • 面试 TOP101 贪心专题题解汇总Java版(BM95 —— BM96)
  • 软件启动时加配置文件 vs 不加配置文件