专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Mybatis Plus学习教程(1):环境搭建

测试环境版本

1、 JDK 1.8
2、 MySQL5.7
3、 Spring Boot

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>

1、 Mybatis Plus

<dependency>
   <groupId>com.baomidou</groupId>
   <artifactId>mybatis-plus-boot-starter</artifactId>
   <version>3.2.0</version>
</dependency>

5、配置数据源和mapper-locations

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/mybatis_plus_demo?useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
    username: root
    password: 123456
mybatis-plus:
  mapper-locations: classpath:/mapper/*.xml

6、设置项目目录机构

73_1.png

7、启动类上添加注解

@MapperScan("com.marco.mybatisplusexample.mapper")

数据准备

准备部门表

create table sys_dept
(
    id          bigint auto_increment comment '部门主键'
        primary key,
    dept_name   varchar(32)   not null comment '部门名称',
    location    varchar(32)   not null comment '地点',
    dept_remark varchar(1024) null comment '部门备注',
    tenant_id   bigint        not null comment '租户id'
)
    charset = utf8;

INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (1, '财务部', '北京', '管很多钱的财务部', 1);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (2, '法务部', '北京', '懂很多法律的法务部', 1);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (3, 'IT部', '北京', '有一群牛逼的程序猿', 1);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (4, '人事部', '北京', '管很多人的人事部', 1);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (5, '财务部', '上海', '管很多钱的财务部', 2);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (6, '法务部', '上海', '懂很多法律的法务部', 2);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (7, 'IT部', '上海', '有一群牛逼的程序猿', 2);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (8, '人事部', '上海', '管很多人的人事部', 2);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (9, '财务部', '深圳', '管很多钱的财务部', 3);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (10, '法务部', '深圳', '懂很多法律的法务部', 3);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (11, 'IT部', '深圳', '有一群牛逼的程序猿', 3);
INSERT INTO mybatis_plus_demo.sys_dept (id, dept_name, location, dept_remark, tenant_id) VALUES (12, '人事部', '深圳', '管很多人的人事部', 3);

文章永久链接:https://tech.souyunku.com/26501

未经允许不得转载:搜云库技术团队 » Mybatis Plus学习教程(1):环境搭建

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们