Closed SDUERLLei closed 1 year ago
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
JDK Version(required): 1.8
SpringBoot Version(required): 2.6.3
dynamic-datasource-spring-boot-starter Version(required):3.3.2
druid Version(optional):1.2.6
使用mybatis-plus会在初始化时指定databaseId,现在databaseId是dynamic-DataSource中配置的primary数据源 如何做到在切换数据源时可以切换为相应数据源的databaseId
Expected Result: 在切换数据源时mybatis-plus可以切换相应数据源的databaseId
Actual Result: databaseId会在初始化bean的时候赋值,无法在切换数据源时改变,执行的总是primary数据源的databaseId对应的sql
If there is an exception,or aop invalid,please attach the exception trace:
Just paste your stack trace here!
Step 1 spring: datasource: dynamic: primary: master datasource: master: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/demo?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai username: root password: 123456 slave: driver-class-name: com.highgo.jdbc.Driver url: jdbc:highgo://127.0.0.1:5866/demo?upperColumnName=true¤tSchema=dgov_bsp&stringtype=unspecified username: root password: 123456
Step 2 @Bean public DatabaseIdProvider databaseIdProvider() { DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); Properties properties = new Properties(); properties.setProperty("Oracle", "oracle"); properties.setProperty("MySQL", "mysql"); properties.setProperty("PostgreSQL", "postgresql"); properties.setProperty("Highgo", "highgo"); // 添加其他数据库厂商的配置 databaseIdProvider.setProperties(properties); return databaseIdProvider; }
Step 3
我只负责切换数据源,其他的不管. 而且databaseId是mybatis底层的. 你应该找mybatis
Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。
Enviroment
JDK Version(required): 1.8
SpringBoot Version(required): 2.6.3
dynamic-datasource-spring-boot-starter Version(required):3.3.2
druid Version(optional):1.2.6
Describe what happened
使用mybatis-plus会在初始化时指定databaseId,现在databaseId是dynamic-DataSource中配置的primary数据源 如何做到在切换数据源时可以切换为相应数据源的databaseId
Expected Result: 在切换数据源时mybatis-plus可以切换相应数据源的databaseId
Actual Result: databaseId会在初始化bean的时候赋值,无法在切换数据源时改变,执行的总是primary数据源的databaseId对应的sql
If there is an exception,or aop invalid,please attach the exception trace:
Steps to reproduce
Step 1 spring: datasource: dynamic: primary: master datasource: master: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/demo?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai username: root password: 123456 slave: driver-class-name: com.highgo.jdbc.Driver url: jdbc:highgo://127.0.0.1:5866/demo?upperColumnName=true¤tSchema=dgov_bsp&stringtype=unspecified username: root password: 123456
Step 2 @Bean public DatabaseIdProvider databaseIdProvider() { DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); Properties properties = new Properties(); properties.setProperty("Oracle", "oracle"); properties.setProperty("MySQL", "mysql"); properties.setProperty("PostgreSQL", "postgresql"); properties.setProperty("Highgo", "highgo"); // 添加其他数据库厂商的配置 databaseIdProvider.setProperties(properties); return databaseIdProvider; }
Step 3