diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 7e2ddb1..865c915 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -117,17 +117,6 @@
mybatis-plus-generator
3.4.0
-
-
- org.apache.shardingsphere
- sharding-jdbc-spring-boot-starter
- 4.1.1
-
-
- org.apache.shardingsphere
- sharding-jdbc-spring-namespace
- 4.1.1
-
org.springframework.boot
spring-boot-starter-test
diff --git a/ruoyi-admin/src/main/resources/application-local.yml b/ruoyi-admin/src/main/resources/application-local.yml
index 0825620..8313311 100644
--- a/ruoyi-admin/src/main/resources/application-local.yml
+++ b/ruoyi-admin/src/main/resources/application-local.yml
@@ -2,66 +2,8 @@
spring:
main:
allow-bean-definition-overriding: true
- shardingsphere:
- datasource:
- names: ds0,ds1
- ds0:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.3.243:3306/epusdt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: Lqj7667213.520
- type: com.alibaba.druid.pool.DruidDataSource
- filters: stat
- maxActive: 20
- initialSize: 1
- maxWait: 60000
- minIdle: 1
- timeBetweenEvictionRunsMillis: 60000
- minEvictableIdleTimeMillis: 300000
- validationQuery: select 'x'
- testWhileIdle: true
- testOnBorrow: false
- testOnReturn: false
- poolPreparedStatements: true
- maxOpenPreparedStatements: 20
- ds1:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://192.168.3.243:3306/epusdt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: Lqj7667213.520
- type: com.alibaba.druid.pool.DruidDataSource
- filters: stat
- maxActive: 20
- initialSize: 1
- maxWait: 60000
- minIdle: 1
- timeBetweenEvictionRunsMillis: 60000
- minEvictableIdleTimeMillis: 300000
- validationQuery: select 'x'
- testWhileIdle: true
- testOnBorrow: false
- testOnReturn: false
- poolPreparedStatements: true
- maxOpenPreparedStatements: 20
props:
sql.show: true
- sharding:
- # 默认数据源
- default-data-source-name: ds0
- default-key-generator:
- type: SNOWFLAKE
- column: id
- default-database-strategy:
- inline:
- sharding-column: id
- algorithm-expression: ds$->{id % 2}
- tables:
- exam_student_paper_answer:
- actual-data-nodes: ds$->{0..1}.exam_student_paper_answer_$->{0..1}
- table-strategy:
- inline:
- sharding-column: id
- algorithm-expression: exam_student_paper_answer_$->{id % 2}
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml
index 993f19f..bf3cb14 100644
--- a/ruoyi-admin/src/main/resources/application-prod.yml
+++ b/ruoyi-admin/src/main/resources/application-prod.yml
@@ -2,66 +2,8 @@
spring:
main:
allow-bean-definition-overriding: true
- shardingsphere:
- datasource:
- names: ds0,ds1
- ds0:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://172.16.0.4:3308/epusdt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: Lgkj@123
- type: com.alibaba.druid.pool.DruidDataSource
- filters: stat
- maxActive: 20
- initialSize: 1
- maxWait: 60000
- minIdle: 1
- timeBetweenEvictionRunsMillis: 60000
- minEvictableIdleTimeMillis: 300000
- validationQuery: select 'x'
- testWhileIdle: true
- testOnBorrow: false
- testOnReturn: false
- poolPreparedStatements: true
- maxOpenPreparedStatements: 20
- ds1:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://172.16.0.4:3308/epusdt?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: Lgkj@123
- type: com.alibaba.druid.pool.DruidDataSource
- filters: stat
- maxActive: 20
- initialSize: 1
- maxWait: 60000
- minIdle: 1
- timeBetweenEvictionRunsMillis: 60000
- minEvictableIdleTimeMillis: 300000
- validationQuery: select 'x'
- testWhileIdle: true
- testOnBorrow: false
- testOnReturn: false
- poolPreparedStatements: true
- maxOpenPreparedStatements: 20
props:
sql.show: true
- sharding:
- # 默认数据源
- default-data-source-name: ds0
- default-key-generator:
- type: SNOWFLAKE
- column: id
- default-database-strategy:
- inline:
- sharding-column: id
- algorithm-expression: ds$->{id % 2}
- tables:
- exam_student_paper_answer:
- actual-data-nodes: ds$->{0..1}.exam_student_paper_answer_$->{0..1}
- table-strategy:
- inline:
- sharding-column: id
- algorithm-expression: exam_student_paper_answer_$->{id % 2}
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java
index 0972e6c..5108230 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java
@@ -9,15 +9,11 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.sql.DataSource;
-
-import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
@@ -30,15 +26,12 @@ import com.ruoyi.framework.datasource.DynamicDataSource;
/**
* druid 配置多数据源
- *
+ *
* @author ruoyi
*/
-@DependsOn("shardingDataSource")
@Configuration
public class DruidConfig
{
- @Autowired
- private ShardingDataSource shardingDataSource;
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties)
@@ -63,13 +56,12 @@ public class DruidConfig
Map