SpringBoot整合MybatisPlus(powernode CD2207)(内含教学视频+源代码)

SpringBoot整合MybatisPlus(powernode CD2207)(内含教学视频+源代码)

教学视频+源代码下载链接地址:https://download.csdn.net/download/weixin_46411355/87452921


整合mybatis-plus

零、步骤

1.导包: 导入Mybatispuls的启动器 、druid、(mysql驱动)
2.配置数据源: 没有区别
3.配置mybatis核心配置:
前缀为mybatisplus
前缀后的内容
4.扫描Mapper包:没有区别

一、创建一个SpringBoot项目

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二、修改pom.xml中SpringBoot的版本,并导入依赖

2.1 修改pom.xml中SpringBoot的版本为2.7.6

在这里插入图片描述

2.2 导入mybatis-plus的依赖

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

2.3 导入druid的依赖

<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.9</version>
        </dependency>

三、使用MybatisX插件逆向生成代码

在这里插入图片描述

在这里插入图片描述
上面点击Test Connection如果报错,报错信息为下面这个的话
Failed [08S01] Communications link failure The last packet successfully received from the server was 89 milliseconds ago. The last packet sent successfully to the server was 81 milliseconds ago. No appropriate protocol (protocol is disabled or cipher suites are inappropriate).
则我们点击Advanced,将useSSL修改为false。
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、application.yml

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://localhost:13306/ssm_power_edu?characterEncoding=utf-8&serverTimezone=UTC
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: root

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:mappper/*.xml


五、启动类加上@MapperScan注解

package com.bjpowernode.springboot32mybatisplus;

import com.bjpowernode.springboot32mybatisplus.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@MapperScan("com.bjpowernode.springboot32mybatisplus.mapper")
@SpringBootApplication
public class Springboot32MybatisplusApplication {


    public static void main(String[] args) {
        SpringApplication.run(Springboot32MybatisplusApplication.class, args);
    }

}

六、测试类和测试结果


package com.bjpowernode.springboot32mybatisplus;

import com.bjpowernode.springboot32mybatisplus.domain.User;
import com.bjpowernode.springboot32mybatisplus.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
class Springboot32MybatisplusApplicationTests {

    @Autowired
    private UserService userService;


    @Test
    void contextLoads() {
        List<User> userList = userService.list();
        userList.forEach(System.out::println);
    }
}




在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
图书管理系统是一个常见的项目,下面是使用 SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios 的图书管理系统的简单介绍。 1. 项目概述 该项目是一个图书管理系统,主要功能包括: - 图书的增删改查 - 图书分类的增删改查 - 图书借阅的管理 2. 技术栈 - 后端:SpringBoot + MyBatisPlus + Restful - 前端:Vue + Jquery + Axios 3. 功能模块 - 登录模块:用户登录、退出登录 - 图书管理模块:图书查询、添加、修改、删除 - 图书分类模块:图书分类查询、添加、修改、删除 - 借阅管理模块:借阅记录查询、添加、修改、删除 4. 项目结构 - backend:后端代码 - src/main/java/com/example/demo:Java 代码 - src/main/resources:配置文件和静态资源 - frontend:前端代码 - src:Vue 代码 5. 实现步骤 - 使用 Spring Initializr 创建一个 SpringBoot 项目 - 引入 MyBatisPlus、Druid 数据库连接池、Lombok 等依赖 - 创建数据库表,使用 MyBatisPlus 自动生成实体类和 Mapper 接口 - 创建 Restful API,提供图书、图书分类、借阅记录的增删改查接口 - 使用 Vue、Jquery、Axios 等前端技术实现前端界面,调用后端提供的接口实现相应功能 6. 总结 该项目基于 SpringBoot + MyBatisPlus + Restful + Vue + Jquery + Axios 技术栈,实现了一个简单的图书管理系统。通过该项目,可以学习到如何使用 SpringBoot 进行开发,如何使用 MyBatisPlus 简化数据库操作,以及如何使用 Vue、Jquery、Axios 等前端技术实现前端界面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FBI HackerHarry浩

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值