spring-data-mybatis icon indicating copy to clipboard operation
spring-data-mybatis copied to clipboard

Support for multiple data sources

Open easybest opened this issue 6 years ago • 8 comments
trafficstars

Support for multiple data sources use @DataSource annotation to determine which datasource will be use. @DataSource support Repository Class and Method level. If not assigned a @DataSource annotation will use primary datasource.

easybest avatar Dec 14 '18 05:12 easybest

Hi @hatunet, wasn't this already possible? I was using multiple data source. Will you this time write a documentation?

kopax avatar Dec 14 '18 11:12 kopax

多数据源功能实现了吗?

shook2012 avatar Feb 22 '19 16:02 shook2012

我看您之前有提交实现多数据源相关功能的代码,后面又删除了。是因为实现的不是你想要的样子? 之前的是可以做到调用不同方法,使用不同的数据源吧。但@DataSource在类上并不起作用,对吧。

shook2012 avatar Feb 23 '19 16:02 shook2012

@DataSource定义在子类的方法上时; 执行CrudRepository父接口的方法时,切面获取不到子接口的@Datasource注解?!

shook2012 avatar Feb 24 '19 06:02 shook2012

有bug

easybest avatar Feb 25 '19 02:02 easybest

如果你有思路 可以给个PR

easybest avatar Feb 25 '19 05:02 easybest

我重写了MultipleDataSourceAspect,不同的datasource的repository放在不同的包,在MultipleDataSourceAspect根据包路径切面来切换数据源了...这个方案可行,但不算是通用方案。

shook2012 avatar Feb 27 '19 06:02 shook2012

AOP不是问题,关键是事务

easybest avatar Feb 27 '19 06:02 easybest