diff --git a/pom.xml b/pom.xml
index e96a1aa..250aec7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,11 @@
org.springframework.boot
spring-boot-starter-data-redis
+
+ org.apache.shardingsphere
+ sharding-jdbc-spring-boot-starter
+ 4.1.1
+
org.springframework.boot
spring-boot-starter-test
@@ -44,8 +49,8 @@
com.alibaba
- druid-spring-boot-starter
- 1.2.8
+ druid
+ 1.2.12
org.projectlombok
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 8f3166d..3db17a2 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,13 +1,40 @@
spring:
+ shardingsphere:
+ datasource:
+ names:
+ master,slave
+ # 主数据源
+ master:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver
+# url:
+ username: root
+# password:
+ # 从数据源
+ slave:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: com.mysql.cj.jdbc.Driver
+# url:
+ username: root
+# password:
+ masterslave:
+ # 读写分离配置
+ # 从库负载均衡的策略,此处是轮询
+ load-balance-algorithm-type: round_robin
+ # 最终的数据源名称
+ name: dataSource
+ # 主库数据源名称
+ master-data-source-name: master
+ # 从库数据源名称列表,多个逗号分隔
+ slave-data-source-names: slave
+ props:
+ sql:
+ show: true #开启SQL显示,默认false
+ main:
+ allow-bean-definition-overriding: true
cache:
redis:
time-to-live: 1800000
- datasource:
- druid:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://localhost:3306/reggie?serverTimezone=Asia/Shanghai
- username: root
-# password:
# redis:
# password: