We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
单独使用Db kit可以正常完成功能,增加https://github.com/baomidou/dynamic-datasource 后发现无法切换数据源。希望增加对多数据源的支持
JDK Version: temurin64-21.0.3
SpringBoot Version: 3.3.5
mybatis-plus:3.5.9
dynamic-datasource-spring-boot-starter Version:4.3.1
druid Version: 无
Mapper上使用@DS注解,多数据源切换在db kit中无法正常切换。
@DS
db kit中使用的mapper是未经dynamic-datasource代理的mapper所以注解未生效。改为service中使用baseMapper则正常。
// entity/Task.java @Data public class Task { @TableId(type = IdType.AUTO) protected Integer id; }
// mapper/TaskMapper.java @DS("old") public interface TaskMapper extends BaseMapper<Task> { }
// Main.java @MapperScan({"com.cc.mapper"}) public class Main { public static void main(String[] args) { SpringApplication.run(Main.class, args); } }
Task task = Db.getById(id, Task.class);
初步定位问题代码:
public final class SqlHelper { public static <T, R, M extends BaseMapper<T>> R execute(Class<T> entityClass, SFunction<M, R> sFunction) { SqlSession sqlSession = sqlSession(entityClass); try { return sFunction.apply(getMapper(entityClass, sqlSession)); } finally { CompatibleHelper.getCompatibleSet().closeSqlSession(sqlSession, GlobalConfigUtils.currentSessionFactory(entityClass)); } } }
getMapper(entityClass, sqlSession) 这里获取的不是最终代理的mapper
The text was updated successfully, but these errors were encountered:
baomidou/dynamic-datasource#682
Sorry, something went wrong.
在做了
VampireAchao
No branches or pull requests
确认
功能改进
单独使用Db kit可以正常完成功能,增加https://github.com/baomidou/dynamic-datasource 后发现无法切换数据源。希望增加对多数据源的支持
参考资料
JDK Version: temurin64-21.0.3
SpringBoot Version: 3.3.5
mybatis-plus:3.5.9
dynamic-datasource-spring-boot-starter Version:4.3.1
druid Version: 无
Mapper上使用
@DS
注解,多数据源切换在db kit中无法正常切换。db kit中使用的mapper是未经dynamic-datasource代理的mapper所以注解未生效。改为service中使用baseMapper则正常。
Steps to reproduce
初步定位问题代码:
getMapper(entityClass, sqlSession) 这里获取的不是最终代理的mapper
The text was updated successfully, but these errors were encountered: