基于EasyCode插件的SpringBoot和Mybatis框架快速整合以及PostMan的使用

参考视频:基于EasyCode插件的Spring boot、Mybatis框架快速整合搭建以及PostMan的使用 点击观看

文章目录

  • [1 创建项目](#1 创建项目)
  • [2 创建数据库](#2 创建数据库)
  • [3 导包](#3 导包)
  • [4 配置application.yaml文件](#4 配置application.yaml文件)
  • [5 使用插件EasyCode](#5 使用插件EasyCode)
  • [6 验证项目是否运行成功](#6 验证项目是否运行成功)
  • [7 使用PostMan测试工具测试接口](#7 使用PostMan测试工具测试接口)

1 创建项目

pom.xml

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.findx</groupId>
    <artifactId>springboot-mybatis-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-mybatis-demo</name>
    <description>springboot-mybatis-demo</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>


2 创建数据库

sql 复制代码
create database malldb default character set utf8mb4 collate utf8mb4_unicode_ci;
# 使用数据库
use malldb;
-- 建表sql
create table mall_user
(
    id            int auto_increment comment '主键id'
        primary key,
    user_id       bigint  default 0                       null comment '用户id',
    user_name     varchar(8)   default ''                null comment '用户姓名',
    user_gender   int          default 0                 null comment '性别',
    user_address  varchar(256) default ''                null comment '用户地址',
    user_birthday timestamp      default CURRENT_TIMESTAMP  null comment '用户生日',
    user_phone    varchar(20)  default ''                null comment '用户手机号',
    create_time   timestamp      default CURRENT_TIMESTAMP  null COMMENT '创建时间',
    update_time   timestamp      default CURRENT_TIMESTAMP  null ON update  CURRENT_TIMESTAMP   COMMENT '更新时间'
)
    comment '用户表';
-- 建立唯一索引
create unique index idx_user_id on mall_user(user_id);
-- 插入数据
INSERT INTO mall_user (user_id, user_name, user_gender, user_address, user_birthday, user_phone, create_time, update_time) VALUES (88880001, 'zs', 1, 'sh', DEFAULT, '15821238534', DEFAULT, DEFAULT);
INSERT INTO mall_user (user_id, user_name, user_gender, user_address, user_birthday, user_phone, create_time, update_time) VALUES (88880002, 'ls', 0, 'bj', DEFAULT, '15821238588', DEFAULT, DEFAULT);
INSERT INTO mall_user (user_id, user_name, user_gender, user_address, user_birthday, user_phone, create_time, update_time) VALUES (88880003, 'ww', 1, 'sh', DEFAULT, '15821238577', DEFAULT, DEFAULT);
# 查看数据库
select  * from mall_user;

3 导包

pom.xml

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.findx</groupId>
    <artifactId>springboot-mybatis-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-mybatis-demo</name>
    <description>springboot-mybatis-demo</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.3.2</version>
        </dependency>
        <!--mysql驱动-->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.0.31</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

4 配置application.yaml文件

yaml 复制代码
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/malldb?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
    username: root
    password: root
    driver-class-name: com.mysql.cj.jdbc.Driver

5 使用插件EasyCode



6 验证项目是否运行成功


7 使用PostMan测试工具测试接口

相关推荐
敖正炀1 天前
Spring Boot + MyBatis 企业级数据访问层实战:从选型到分库分表的深度演进
mybatis
MZ_ZXD0011 天前
springboot音乐播放器系统-计算机毕业设计源码76317
java·c语言·c++·spring boot·python·flask·php
敖正炀1 天前
多数据源与读写分离中间件
mybatis
胡楚昊1 天前
BUU WEB之旅(1)
java·数据库·mybatis
azhou的代码园1 天前
基于微信小程序的图片识别科普系统的设计与实现
vue.js·spring boot·微信小程序·小程序·毕业设计·科普·图片识别
Filwaod1 天前
互联网大厂Java面试实战:Spring+Redis+MySQL+JVM场景问答深度解析
jvm·spring boot·redis·mysql·java面试·技术面试·互联网大厂
安当加密1 天前
Spring Boot应用接入国产安当凭据管理系统SMS Starter实战(附源码)
java·spring boot·后端
敖正炀1 天前
MyBatis 通用插件库与性能监控平台
mybatis
Filwaod1 天前
Java面试现场:从Redis缓存到分布式事务,水货程序员李四的‘表演‘
java·jvm·spring boot·redis·mysql·面试·多线程
Filwaod1 天前
互联网大厂Java面试实战:从Spring Boot到AI智能客服,水货程序员李四的翻车现场
spring boot·redis·mysql·spring cloud·微服务·ai·java面试