10、MyBatis-Plus 多数据源

第一篇:1、Mybatis-Plus 创建SpringBoot项目
第二篇:2、Mybatis-Plus 测试增、删、改、查
第三篇:3、Mybatis-Plus 自定义sql语句
第四篇:4、Mybatis-Plus 通用service的操作
第五篇:5、Mybatis-Plus 常用注解
第六篇:6、Mybatis-Plus wrapper的使用
第七篇:7、Mybatis-Plus condition的使用
第八篇:8、Mybatis-Plus 分页插件、自定义分页
第九篇:9、Mybatis-Plus 乐观锁

1、介绍

在这里插入图片描述

2、创建数据库和表

CREATE DATABASE `mybatis_plus_1` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; 
use `mybatis_plus_1`;
 CREATE TABLE product ( 
id BIGINT(20) NOT NULL COMMENT '主键ID', 
name VARCHAR(30) NULL DEFAULT NULL COMMENT '商品名称', 
price INT(11) DEFAULT 0 COMMENT '价格', 
version INT(11) DEFAULT 0 COMMENT '乐观锁版本号', PRIMARY KEY (id) );

INSERT INTO product (id, NAME, price) VALUES (1, '外星人笔记本', 100);

3、引入依赖

<dependency>
 <groupId>com.baomidou</groupId>
 <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
 <version>3.5.0</version>
</dependency>

4、配置多数据源

在这里插入图片描述

5、创建用户service

在这里插入图片描述

6、创建商品service

在这里插入图片描述

7、测试

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

猜你喜欢

转载自blog.csdn.net/weixin_43304253/article/details/126823993