# springboot动态注册与切换数据源 **Repository Path**: huchenyang/dynamic-data-source-jpa ## Basic Information - **Project Name**: springboot动态注册与切换数据源 - **Description**: 整合动态数据源创建、动态切换数据源,使用框架:springboot2+oracle+jpa+druid - **Primary Language**: Java - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 10 - **Forks**: 3 - **Created**: 2021-07-26 - **Last Updated**: 2024-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # dynamicDataSourceJpa #### 介绍 整合动态数据源创建、动态切换数据源 #### 软件架构 使用框架:springboot+oracle+jpa+druid #### 测试数据源接口: ![输入图片说明](https://images.gitee.com/uploads/images/2021/0726/204517_9a5f57dd_1477577.png "屏幕截图.png") #### 数据源表结构 ![输入图片说明](https://images.gitee.com/uploads/images/2021/0726/204410_360bac30_1477577.png "屏幕截图.png") #### 创建表空间及用户(多数据源) ``` create tablespace moredb logging datafile 'D:\db\moredb\moredb.dbf' size 50m autoextend on next 50m maxsize 20480m extent management local; create user moredb1 identified by 123456 default tablespace moredb; create user moredb2 identified by 123456 default tablespace moredb; create user moredb3 identified by 123456 default tablespace moredb; grant connect,resource,dba to moredb1; grant connect,resource,dba to moredb2; grant connect,resource,dba to moredb3; ``` 创建数据库的sql,见文件夹:sql #### 主数据源/动态数据源 1. 主数据源jpa实体目录:com.rzt.entity 1. 动态数据源jpa实体目录:com.rzt.moredb.entity #### 使用说明 系统跑起来,访问浏览器:http://127.0.0.1:8081/swagger-ui.html 希望能够帮助大家,此项目的思想可以延伸到读写分离或分表需求