baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.76k stars 1.2k forks source link

启动时报错,工程正常启动2 手动切换数据源失败 #583

Closed HYDCHAO closed 1 year ago

HYDCHAO commented 1 year ago

Please fill it out carefully, or it will be closed. 请认真填写,不然会直接关闭。

Enviroment

JDK Version(required): 1.8.0_371 SpringBoot Version(required): 2.5.3 dynamic-datasource-spring-boot-starter Version(required): 4.1.3
druid Version(optional): 1.2.6

Describe what happened

启动时报错,工程正常启动后,调用涉及手动切换数据源的方法,失败,报错。已核查没开启事务 (该方法在dynamic-datasource-spring-boot-starter 版本是 3.1.1 的时候能够正常使用,升到4.1.3 后不行了)

Expected Result:

数据源正常切换

Actual Result: 数据源切换失败,查询的还是msater 库,该表在msater中不存在

If there is an exception,or aop invalid,please attach the exception trace:

Just paste your stack trace here!

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql : 
 SELECT COUNT(1) FROM f_csbd 

Steps to reproduce

huayanYu commented 1 year ago

请给出示例demo