读写分离控制

This commit is contained in:
dingzhongyuan 2021-06-21 17:30:48 +08:00
parent f8ef90ab98
commit d416394e7e
3 changed files with 6 additions and 8 deletions

View File

@ -15,6 +15,8 @@ spring:
login-username: ruoyi
login-password: 123456
dynamic:
#是否开启读写分离
ms: false
druid:
# 初始连接数
initialSize: 5

View File

@ -14,6 +14,8 @@ spring:
login-username: ruoyi
login-password: 123456
dynamic:
#是否开启读写分离
ms: false
druid:
# 初始连接数
initialSize: 5
@ -37,14 +39,6 @@ spring:
filters: stat # 注意这个值和druid原生不一致默认启动了stat
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true

View File

@ -22,7 +22,9 @@ import java.io.IOException;
public class DynamicDataSourceConfig {
@Bean
@ConditionalOnProperty(name = "spring.datasource.dynamic.ms", havingValue = "true")
public MasterSlaveAutoRoutingPlugin masterSlaveAutoRoutingPlugin(){
System.out.println("-----------读写分离已开启------------");
return new MasterSlaveAutoRoutingPlugin();
}